Add Me!Close Menu Navigation

... and these are my notes about flash, flex, actionscript, ria, mobile

Add Me!Open Categories Menu

Google Cloud Messaging Push Notifications – native extension for air on android

I think push notifications are a must nowadays for mobile apps. Awesome in one word! Maybe just because I could not implement them until now without native extensions.
Looked around for already made solution and found two: one free here from Afterisk and one paid here from Distriqt (this also includes many other cool extensions and for iOS too).

But since I was gonna do it my way, that means not using foreign code :), I started reading all kinds of tutorials about GCM starting from here. I’ve managed to do it in native Android, but not quite do it in a native extension for air (adobe native extensions tutorials here). My problem was some permissions and the way they had to be included in the manifest file. So I gave up since the deadline for my project was right around the corner and followed Afterisk’s tutorial and code.

First of all you need the Project Number (not the Project ID) from the Google APIs Console where you enabled GCM. You will need this when you’ll want to register a device for notifications.
From the API Access tab you will need to create keys for those who want to send notifications to subscribed clients (for example your java sever, or your php file.. ) and you also can restrict access so no one else is using your account to send notifications to those clients. If you are curios to test it find this attached native android sources here. Notice the permissions needed and entered in the manifest. (just replace YOUR PROJECT NUMBER FROM THE GOOGLE APIS CONSOLE with your project number). How to test it? After you receive a registration ID from GCM server you enter it here in the first field. The sources for this php file are here.

Afterwards you will want to use this awesome thing in your air app. Download the latest files from Afterisk and follow their instructions. Flash Builder test project is here.
For the extension to work in debug mode you have to add .debug in 3 places – see the manifest file from the Flash Builder project.

<permission android:name="" android:protectionLevel="signature" />
<uses-permission android:name="" />
<category android:name="" />

When you release your application you will have to delete the .debug appearances from the manifest file.

So the extension works, you receive the notifications, Afterisk is great, now the final touch would be changing the icons that appear on top of your phone in the notifications bar. Download this zip file from over here, unzip it, change your icons in that folder and run generateANE.bat. You will have to have adt in your path. Voila! Simple isn’t it?

PS: one more thing, if you try to unregister, the GCM servers have a delay until they really unregister you for good

Posted By marius

35 Responses to “Google Cloud Messaging Push Notifications – native extension for air on android”

  1. Roman says:

    Nice solution!
    I was trying to implement GCM also but with no luck. I don’t receive even registrationID from google cloud after sending this:
    _gcmi.register(266618942147);//266618942147 is my Project Number from Google Api page. So GCMEvent.REGISTERED never invoked and I have no ideas how to fix it.
    Marius, doesn’t you know how to handle it?

    • Frank says:

      Doesn’t your “register” call’s response already contain the token? In my case it does.
      From what I’ve understood, the REGISTERED event can be called periodically of Google decides to change the token, though I don’t know how often that happens as they don’t tell. So far, I haven’t received that very event and I’m testing this ANE for two days now.

    • marius says:

      send me your sources and will let you know if I find a solution.

    • Florian Matoflink says:

      Hi, i’m having the same problem. Did you fix it ?

  2. marius says:

    Check your permissions in the manifest file. Be sure to add .debug where it needs if you launch in debug mode, otherwise the native extension won’t find the context of the air app.
    Be sure to use your app id in the manifest the correct way.

  3. Roman says:

    Hi, I’ve sent project Number to cloud and received registrationID in console:
    GCMPushInterface: registered Status Listeners
    GCMRegistrar: registering sender 582879173960
    GCMPushInterface Status: APA91bEZFAn3_FPWK9ch3pkEZ6kd-I8B-3P8Nxxxxxxxxxxxxxxxxxx-lSLVPX6nL-q3cGziIMB9oiU6zmZkRpG8V5IT2Ns21G3kiJ6uBARIuvFXJvXF9ka0QrayO07e0-haabq4Ze000DigJasy34QQm8A
    GCMPushInterface Code: registered
    but after sending 3 parameters { ‘apiKey’ : AIzaSyCUnN4qPyJhjim9R0EZs7tAwqhvUfI-EY8, ‘message’ : someMessage, ‘id’ : APA91bEZFAn3_FPWK……..}; to php I receive this fault request
    Please, help to fix it

  4. Tica says:

    Hi man, thanks a lot. I found the native extension on Afterisk blog, but couldn’t change the icons. Kept getting “Invalid swc file” error no matter what I did. Anyway your .bat file worked like a charm. I’m just sorry I didn’t read all the comments before trying to change the icons on my own.

    Thanks again

  5. sanal says:

    while debugging its working fine i am able to get the notification but when i made a release build the application doesn’t works properly :(

    • marius says:

      For the extension to work in debug mode you have to add .debug in 3 places – see the manifest file from the Flash Builder project.

      this must be it. Of course in release you have to ommit the .debug in the manifest.

  6. awesomeness says:

    Hello, Thanks so much for this ANE. It’s the best one yet because you created it in a way that allows for using your own icon. which is a must. It pretty much makes the others pointless.

    However the only issue that still keeps this one from the full potential is the fact it does not make a sound or vibrate. Could you possible make an update that has a sound? Maybe it could be saved on the SD card. Or maybe just use the phone’s default sound (anything is better than nothing). Also if it’s possible vibrate would be nice. But sound is the most important. Maybe the sound could be named something and compiled with it the way you have us compile the icon.

    What’s the pont of a notification if you don’t hear it? Please consider making an update with sound. Thank you! I’ll be checking back regularly.

  7. saint says:

    Great work guys… how about sounds and vibrations?… any thoughts about that, any plans to implement it? Is it possible with patch or it must be built in the original .ane?


  8. Saqib Ahmas says:

    Thanks, its a perfect article and worked very well, if some one face the issue that the he only get “GCMRegistrar: registering sender xxxxx” and never registered ID, do test his App id it must be according to the services and permissions. thanks once again.

  9. Saqib Ahmas says:

    An Other Thing, if system through “adt is not a recognized command” update system variables “Path” with your Flex SDKs bin folder.

  10. Kevin says:

    Hi marius.

    First of all, thank you for great tutorial. It’s very helpful.

    But, I’m new to Flex. so Can I get your Flash Builder test file? The link was broken.
    I’ve spent very long times. Because of GCM-ANE. You can be my sunshine. :) Please Please help me.

    Thanks in advanced. and sorry for my poor English.


  11. Rey says:


    Thank you so much for this article!
    But, I have a probrem. Could you please give me some hints?

    I can get registrationID and get message from GCM.
    When I get GCMEvent.MESSAGE event, the event.message is “type:null,id:null”.
    I hope that some string is in type and id parameters.
    I tried with AIR SDK3.5 and SDK3.7 but both didn’t work.

    I’m not sure that you can understand my words because of my lack of English skill…

    Any comment is welcome.

    Thank you.

  12. Sanchit says:


    I have followed the afterrisk tutorial and got the extension working. Just want to change the icons. I have downloaded your zip file for the icons with the gcm.ane and extension.swc. I am stuck somewhere and have few questions to ask here.

    I have adt in my path. After running your generateANE.bat file, do I need to change my working gcm.ANE with yours ? Cause right now its not at all changing the notification icon. And if I change it. Then it gives me an error while debugging ‘GCMinterface not found’.

    I am using flash builder 4.6 with AIR 3.1. And for adt i have downloaded AIR 3.8 on the C drive. Is this causing the issue ?

    I have tested with your test Project as well. Giving me the same not found error.

    Do I need to add the the gcm.swc ? Because I can see that in your Project. My project is working fine with only gcm.ane.

    Must be some fullish mistake that I am making. Thanks in advance.

  13. Sanchit says:


    this is the error I am getting after I use your ANE file

    “VerifyError: Error #1014: Class com.afterisk.shared.ane.lib::GCMPushInterface could not be found.

    • Monica says:

      I couldn’t agree more about gareitrics. I miss sitting with some of the elderly individuals I used to help and they would tell me stories for hours about the things that they witness when they were younger, and the lives that they lived up to the point that they needed care. I have always felt that the elderly know how to live their lives better than anyone, and they for sure never take it for granted! Sometimes the people taking care of them are not good people though, and it always breaks my heart to see someone talking badly to an elderly man or woman.I like how you made a switch from little tiny babies that have no real experience with life, to elderly men and women who have lived life to its fullest and still have more life to share with others. Such opposites!

  14. Manjit says:

    “there are packaging errors/warnings. Check each native extension in the flex build”
    please help me I am stuck here. thank you

    • Mehmetcan says:

      Breakfast with Santa! Saturday, December 1st from 9-11AMOssian United Methodist Church201 W. Mill Street in Ossian, In 46777Come have pancakes, deiuicols egg casseroles, smoky links, cereal, donuts, dutch crunch dessert, Coffee, milk and juice something for everyoneHave your children’s picture taken with Santa and then they can shop in the Elf Store for their family members. Elves will be available to help them shop so they can keep it a surprise! All gifts are $2 and gift wrapping is included. This is a fun, holiday event sponsored by the Norwell High School Show ChoirSee you there!

    • Eeda says:

      . HOWEVER, Woman B claimed she had never said anithyng to A about my wife spreading the rumors and that she was simply concerned about her. She was sorry, apologized, but understood if my wife didn’t trust her as a friend. My wife was hurt, but choose to forgive woman B and move on and attempt to repair things with woman A.The next morning, woman B went to A and told her what my wife had done to her. Woman A was concerned about the accuracy of the information she was getting from B. Woman A asked her again if she was sure that what she had said at the party was true, including the party about my wife telling many different people and maliciously attempting to start the rumors. B said this was all true again, and that my wife was really upset with A and wanted to bring her down with what she said.A week later, my wife tried to talk to woman A to apologize for what was said. Woman A would not even look at my wife. She said she was done with her as a friend. She explained that woman B had come back to her to tell her she had been talking about her AGAIN, and she reiterated about the fact she had been spreading the rumors maliciously and my wife wanted to hurt woman A. None of this was true. Woman A called my wife a slew of fowl language in front of me, in front of dozens of her close friends and in front of many of my wife’s friends. She stated that she was lying because woman B had said these things to her twice, and that she wouldn’t lie.My wife is woman A’s boss. Woman A is letting this effect her work. Woman A has cut off all communication with my wife outside of work. Woman B is now completely avoiding my wife entirely as well as woman B’s husband, who is a close friend of mine.My wife forgave them both for what happened. Several weeks has passed. I have a hard time forgiving these people and wanted them to ever be back at our home. They were both very good friends of my wife’s and now she feels alone and isolated because her two best friends destroyed their friendship. I even lost a close friend. The collateral damage goes very deep, since these were mutual friends of almost everyone we know.My wife wants me to move on, but I have such a hard time with that. My wife was trying to do the biblically accurate thing to hold a fellow sister in christ accountable and her other sister in christ; who was not a new christian, but a strong one, threw it in her face. She broke her trust not once, but twice.I just think she doesn’t need to be friends with these people if this is how they treat their relationships. I don’t feel comfortable having them around my home if this is what they choose to do.What do you think?

  15. MathBRMD says:

    Hello everybody,

    I’m using flex 4.9, when I try to use the GCMtest, I got the same message as Manjit : “there are packaging errors/warnings. Check each native extension in the flex build”

    I don’t know why ?

    Please, help us. Thanks guys :)

  16. rin says:

    first of all, thank you for the article.
    i want to ask about this sentences

    Download this zip file from over here, unzip it, change your icons in that folder and run generateANE.bat. You will have to have adt in your path

    if i’m not wrong, ADT is the plugin for eclipse, isn’t it?
    can you explain more? because i need to change the notification’s icon

    thank you very much

    • MathBRMD says:

      Hey rin, the tutorial is working for you ?

      Cause I try to use the test project, when I use the .apk in the project, it works, but when i’m trying to compile and use the .apk generated, it not displaying the regID… If you have advices for me…

      Thanks, and sorry for my bad english :/

    • Anisio says:

      For me this is a relatively easy quetoisn, but has a pretty complex answer. The specialty I have actually looked forward to working with is OB/GYN. I find that the ability of a woman’s body to produce a child, endure the amount of abuse it takes during a pregnancy, and the amount of pain endured during delivery is amazing. The joy of being able to be present as life enters the world is truly one of the greatest moments in life. To me that would be the best possible option. I also would love working in the operating room with a surgeon. I have experienced the OR quite a few times, and have been on both sides of the table. I have to say I would love to work with any surgeon in the OR except for Orthopedics. The reason behind that is the surgery’s are pretty brutal when it comes to the skeletal system. Having been in the OR with an Orthopedic surgeon and seeing the use of the saws, hammers and other heavy equipment in order to perform the surgery just sends chills up my spine. I know that type of surgery is not for me. I think my favorite surgeries have to be that of the abdominal cavity. The specialties that I would least like to work for are few, and for simple reasons. Pediatrics is not a specialty for me since I have four children of my own. My Aunt is a neonatal nurse practitioner and I followed her in high school and saw the good, the bad, and the ugly so I can honestly say I could not emotionally handle that type of position. Podiatry is also an area I could not see myself working. The reason behind this is pretty silly, but here goes, I very much dislike other peoples feet especially if they are not well kept. I know in the medical field you will encounter feet on a daily basis, but I could not mainly work with feet on an everyday basis. My last specialty is Orthopedics for the reasons I noted above about the barbaric nature of the surgeries and treatments for the musculoskeletal system. Its just not for me.

    • Indian says:

      Way to use the internet to help people solve preolbms!

    • Diane says:

      The various pjioectrons of future climate in IPCC 2007 (AR4) are actually based on different climate models. The various scenario storylines in the SRES (2000) required a “quantification” based on a specific model. Several such models were available. Some 40 outcomes (specific models applied to specific scenarios) were run.In fact, there was at least one model providing predictions for all scenarios (the so-called Message quantification) but it was not designated as the common quantification of SRES scenarios. Instead, each marker scenario (A1B, A2, B1 and B2) was quantified with a different model. As these models differ in many ways, the different outcomes of each scenario are due not only to the scenario itself, but to the different peculiarities of the models used for each. The IPCC database of climate pjioectrons contains all the variants for each scenario, but only one is usually discussed. The issue is seldom if ever discussed, and is not touched upon in AR4. The SRES reports on the quantification of storylines without discussing the reasons for choosing different quantifications for different scenarios, and not discussing the implications either.Now a new vintage of scenarios is being prepared. I hope this matter is considered in a more explicit and consistent way.

  17. Nikolay says:


    Help me please – i want to view all push alerts in the mobile notification area, one after the another. Now i view only last.


  18. Al says:

    Any news about sound and vibration?

  19. leo says:

    well i couldn’t make it work.
    i downlowded your fxp which was imported on flashbuilder 4.6. i created a new project on google console and added the gcm for android.
    i replaced your project number with the new projects number.
    it compiles fine and runs on my phone, and registers when the app starts but from there i have no idea what to do.

    should i get a message or something on my console with the id of the smartphone?
    can you provide more info on how to use your php to push a notification on my smartphone-app?

  20. Carmina V. says:

    Intr-un final am gasit si eu ceva interesant de citit!

  21. A la luz de las nuevas evidencias a nivel científico, el día de hoy se recomiendan unas reglas mucho más laxas y respetuosas con las costumbres culturales y gastronómicas, conociendo las necesidades reales de alimentación de nuestros lactantes.

Leave a Reply