The only free and fully functional Android GCM native extension for Adobe AIR


This tutorial is about native extension for Adobe AIR and GCM (Google Cloud Messaging) which is a free service provided by Google that allows messages to be pushed to devices of your app users. If anyone is interested in more information on how to create an Android app capable of reception of GCM messages please check out this article on Google dev portal: GCM Tutorial.

In the course of development of  a new social drawing app “Sketch Guess”, we wanted to add an ability for the server to notify players when important events occur in the game and display the appropriate view when the application resumes or restarts (the “fetch message payload after app just launched” capability is only implemented in our own solution so far). While there is an abundance of Adobe AIR native extensions for iOS, there was definitely a gap to be filled for Android applications.

The only way to proceed was to create our own extension which I’m going to provide here for download along with a fully functional example application and a set of instructions below.

The extension is made for Adobe SDK 4.6 + AIR SDK 3.1 . Although, I’m sure it’ll work with 4.5 and 3.0 or newer versions. My weapon of choice in developing Air things is Intellij 10 or 11, so I won’t be providing exact procedures to link to “.ane” when you setup the project since that varies from environment to environment.

Anyway, first things first. Please download the archive which contains extension and the example application from here. The package also contains APK which can be installed to any Android 2.2 +  right away and tested (it uses GCM sender ID of one of our test apps).

Actual extension “gcm.ane” is located in “ane/” folder and can’t be used right away for your own project (the usage can be seen in example application).

Compile and run example application

After downloading create a project for the example application in the IDE of your choice (Intellij, Flash Builder, Flash Develop, Flash CS) and use the following class as the main/application class:

“com.afterisk.gcmdemo.GCMExample” and the output swf file as “GCMExample.swf ” (I’m using ‘bin’ folder as output folder).

In dependencies of your project, specify a new library that includes “gcm.ane”. That should get rid of all the missing references application has. If you are using Flash Builder older than 4.6 or Intellij 10 you might want to duplicate gcm.ane and rename it into “gcm.swc” in order for the compiler to recognize the references.

Create a run configuration (to run on device) that uses the provided “gcm-air-app.xml” descriptor file, connect your device via USB and compile. That is really all that’s needed!

Use extension in your own application.

First you need to obtain your own Sender ID it’s on the lower part of your application page on Android Development Console. It looks like this:

GCM Sender ID

In order to obtain for your app you need to go here and follow Google’s instructions. Once that is done, replace the value of public static const GCM_SENDER_ID:String with your own senderID.

Now, insert the following part of provided application xml into your own application xml (things that need to be updated with your own data are highlighted):

<!-- Specify Android specific tags that get passed to AndroidManifest.xml file. -->

<!--[<span class="hiddenSpellError" pre="">CDATA</span>[-->

<!-- App receives GCM messages. -->

<!-- GCM connects to Google Services. -->

<!-- GCM requires a Google account. -->

<!-- Keeps the processor from sleeping when a message is received. -->


<!-- End of the schema for adding the android specific tags in AndroidManifest.xml file -->

Where you see “” in descriptor xml you must update it with the ID you are using for the application and prepend it with “air.” (You need to do this because all AIR applications are added “air.” in front of the package name.)

Example of application id:


The references to that in GCM part of manifest should be:

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


<category android:name=”” />

If you entered everything correctly you can create a run configuration and run the app on your device while using your own sender ID!

Sending and Receiving

There are certain parameters that this native extension expects to receive:

“title” – a title of message that shows in notification bar (optional).

“alert” – a message shown to users in notification bar, when notification is received and the application is either in the background or not running.

“type” – type of notification. You can put any string data into it, this parameter will be sent to client as a part of String typed message when application launches or resumes from notification.

“id” – same as “type,” another piece of data that is sent as part of String message (again, anything can be placed into it!).

Here is a PHP example showing construction of GCM payload (full class attached):

$message = array('title' =&gt; 'Sketch Guess', 'alert' =&gt; $user . ' created a new sketch!', 'type' =&gt; 'sketch_created', 'id' =&gt; $gameid);

$fields = array('registration_ids' =&gt; $registration_ids, 'data' =&gt; $message);

In AIR, if you trace your GCMEvent message property it will look something like this: “type: the_value_of_type_parameter,  id:  the-value_of_id_parameter”.

You can parse it however you like. Here is my example of the GCMEvent.MESSAGE “message” property parsing:

var pairs:Array = (message.split(&quot;,&quot;));
var space:RegExp = /&quot;/g;
_notificationType = String(String(pairs[0]).split(&quot;:&quot;)[1]).replace(space, &quot;&quot;);
_id = String(String(pairs[1]).split(&quot;:&quot;)[1]).replace(space, &quot;&quot;);

This extension will send events wether the app is in the background or not to determine your app status use the following events, and handle GCM events apppropriately:

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true); 

Based on the parameters of “id” or “type” you can now show an appropriate view to your users.

The example of fully working GCM messaging on Android can be seen in our new drawing game:

Click to view Sketch Guess, the social drawing game, implementation.

I hope the extension we created will help you with GCM messaging implementation.

Good luck!


Again, here is GCM Extension and Example download link.

PHP Class to push messages to GCM service: GCM.php

GitHub address:

Support Us


  1. Mauricio

    When a try publish de example with cs6 a get de error:
    aapt tool. no resource found that matches the given name ‘android:Theme.Holo.light.DarkActionBar

    • afterisktech

      Hello Mauricio,
      I found the issue, my I had styles attached to resources in “res” folder that comes with the jar. I removed those and tested. Works fine. I replaced the projet .zip with the new one. Let me know if it works.

      • Mauricio

        Hello afterisktech,
        Works IN CS6 :), Great job!
        After many tests with others ANE, i see finally in my Android the message: “registrationiD: ASASASDSHSDHSDF…”
        Thanks Again

    • Mauricio

      Can you help me, please.
      The message send by server with php code below, show always in the
      private function handleMessage(e:GCMEvent):void {
      _payload = e.message;
      GCM payload received:type:null,id:null.

      $message) );
      echo $response;

      function sendNotification( $apiKey, $registrationIdsArray, $messageData ){
      $headers = array(“Content-Type:” . “application/json”, “Authorization:” . “key=” . $apiKey);
      $data = array(‘collapse_key’ =>”score_upda”,’data’ => $messageData,’registration_ids’ => $registrationIdsArray);
      $ch = curl_init();
      curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
      curl_setopt( $ch, CURLOPT_URL, “” );
      curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
      curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
      curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
      curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($data) );
      $response = curl_exec($ch);
      return $response;

  2. Mauricio

    php code is incomplet,:
    $message = “the test message”;
    $registrationId = ‘APA91bEO-…._bZYelgAl_u9b5Vw’;
    $apiKey = “gggggggsddsdsdsds”;
    $response= sendNotification( $apiKey, array($registrationId), array(‘message’ => $message) );
    echo $response;

    • nick

      Can someone please post an example of the PHP code, the sample provided is not helpful for a non PHP person

      many thanks

  3. afterisktech

    Ok I think I see the problem, I have a certain format for parsing, that you’d have to reuse. First of all I’m attaching a php class that I’m currently using (its at the bottom of the post). Try to use it or at least take it as a model. Everything must go into “data” (you may call it something else), but 3 things that my ANE accepts are:
    “alert” (something you show to users in notification bar)
    “type” (type of notification, you can put any data into it), thats what gets sent into your client
    “id” is another one that gets to flash, that one also transfered into client app.

    You can reuse “type” and “id” for your internal purposes, and use “alert” for copy for users.


    $message = array( “alert” =>$user . ” created a new sketch!” , “type” => “sketch_created”, “id” => $gameid);
    $fields = array(
    ‘registration_ids’ => $registration_ids,
    ‘data’ => $message);

    Added this to “Sending and Receiving” section of tutorial.

  4. afterisktech

    Updated the parameters. Now you can add “title” (optional) Example:

    $message = array( “title” =>$yourtitle, “alert” =>$user . ” created a new sketch!” , “type” => “sketch_created”, “id” => $gameid);
    $fields = array(
    “registration_ids” => $registration_ids,
    “data” => $message);

    Please download updated ane.

  5. Elie

    i download the new zip file, i extract the ane and add to my flex mobile project.
    and i manipulate the config file as described above.

    When i invoke gcmi.register(GCM_SENDER_ID);
    the return will be CMRegistrar: registering sender XXXXXXx

    and handleRegistered is never called.

    do i need to set any option on the GCM part.

    Thank you

    • afterisktech

      Did you try to install the demo project provided as is? It does work for me. I say, try that first then change sender id while keeping the rest same way, and we’ll go from there.

      • Elie

        Hi, I have great news, i am able to run it, the missing part was to add “debug” after id
        but what i am facing right now is: if run the app on my android tablet, without connecting it with cable, i am not receiving any notification.
        am i missing any a uses-permission (at this level i removed the “debug” syntax)

        Thank you

  6. Eric

    Is possible change the side icon in notification bar?
    can i use custom icon?
    and “type” => “sketch_created” <= this action?

    • afterisktech

      It is possible though it requires recompilation of ane. What you need to copy the “gcm.ane” somewhere else, rename it into “” deep inside of the extracted folder you’ll see folder called “res”. In that folder icons for various resolutions are stored. Replace the “nofify” icons with yours, delete “library.swf” and then rebuild extension using ADT tool (run it from within ANE folder you’ve been). If you are unfamiliar on how to build an ane, please refer to Lee Brimelow tutorials on the subject.

  7. Alfredo

    Hi afterisktech,
    thanks for this great ane.
    I need your helping getting this ane to work. I follow all your instructions to the letter, but I cannot register my device using your sender id. The registration handler is never called. I try with my own sender id and the corresponding changes to the manifest file but no luck either.
    The app just sits there and nothing happens. How could I debug this problem? Am I missing something?

    Thank you so much for your help.

    • afterisktech

      Can you please post, traces from the app (run provided apk on device, while in debug mode via usb and copy traces from console). I did just run demo that is in the archive and i do get good results:

      [trace] GCMPushInterface: registered Status Listeners
      [trace] GCMRegistrar: registering sender 863211319405
      [trace] GCMPushInterface Status: APA91bGX4X7-N4c9BznDpnpRATs3cRHe-xxxxxxsLz8wx73C8IFyrTksvQB9A9hg
      [trace] GCMPushInterface Code: registered

      • Robert Black

        The demo app works flawlessly.
        However when trying to use the ANE in my own app, I notice there’s no option to register a server. My instance also hangs and never registers my senderID.

        • afterisktech

          Hello Robert,
          first you don’t need to register server. The server key just needs to be placed into your code on backend and that serves as the validation for GCM to accept messages from you.

          Lets start with a smaller step then completely different app. Use my sample app but change senderID in it and recompile the apk. See if that works. I’m wondering if there is something wrong with your descriptor xml….

  8. sing2gather

    Hi afterisktech,
    I’m trying your ANE. I get my registrationID but when I try to send pushNotification I don’t receive any notifications on my device.
    I never go in the handleMessage or handleError methods.
    I call in my backend php teh same parameters than you.
    Do you have an idea why I never receive notifications ?

    • afterisktech

      Hello sing2gather,
      Are you using your own sender id, does registration complete just fine? judging by the response it worked. That means device id was registered. The issue might be that the device id you are using is not associated with the app you’re trying to receive message with (Those ids change from app to app, even for the same app published differently) you need to re-register device id each time you run the app, this is recommended practice.

      • sing2gather

        Yes I use my own sender id, and i think registration is complete.
        How can I associated my device id with my app. It’s not something automatic when you register to GCM width the sender id and get your registerID ?

        • afterisktech

          Yeah its automatic, what i was thinking that you registered id maybe with my sample app then using it for your own…maybe thats not the case…
          Another thing is you might be missing parameters when you are sending the message, or providing a different format?

      • sing2gather

        No I’m using the registered id with my own app. I have created a new class where I put all the code of your sample project in it and put trace in each events. When the app is launched I never see the trace and when the app is in background I never receive notifications.
        I also tried to recompile your sample project, get the registered id obtained and try to get notification with the new sample project but it is the same thing, I get no notifications.
        Do you think is it possible I don’t receive notifications if my backend code send the parameters (title, alert, id and type) in a wrong format ?

      • sing2gather

        I’ve just read that GCM uses some specific ports. Maybe my company blocks them, I’ll try to get notification in 3G and not in wifi tomorrow. Maybe it’s just that (I hope 🙂 ).
        “Note: If your organization has a firewall that restricts the traffic to or from the Internet, you’ll need to configure it to allow connectivity with GCM. The ports to open are: 5228, 5229, and 5230. GCM typically only uses 5228, but it sometimes uses 5229 and 5230. GCM doesn’t provide specific IPs. It changes IPs frequently.”

      • sing2gather

        I confirm the problem was the firewall of my company. In 3G I receive the notifications without problems 🙂

  9. sing2gather

    This is the kind of response I receive from my backend service, so I think it seems to work from here :

  10. sing2gather

    Hi afterisktech,
    It is possible with your native extension to add a sound when we receive a notification ? And if it’s possible how can we setup that ?
    Thank you.

    • afterisktech

      Its not possible with current extension because it defaults notification options to android system default settings. It will require additional development to add sound (Basically init needs to identify if sound setting should be overridden). I can add it in the next version, but i’m quite busy at the moment…

      • sing2gather

        Ok no problem. If you can make a second version with sound it will be awesome 🙂
        I’d also like to package the ane to change the icons when I receive a notification, but I don’t have the .swc to package it with my own icons.
        Can you add it please ?
        Thanks a lot !

        • afterisktech

          You can add it yourself. A secret: .ane is pretty much .swc if you rename it. also it is essentially a .zip file. I gave instructions on how to update icons to other person here, here is the copy-paste:

          It is possible though it requires recompilation of ane. What you need to copy the “gcm.ane” somewhere else, rename it into “” deep inside of the extracted folder you’ll see folder called “res”. In that folder icons for various resolutions are stored. Replace the “nofify” icons with yours, delete “library.swf” and then rebuild extension using ADT tool (run it from within ANE folder you’ve been). If you are unfamiliar on how to build an ane, please refer to Lee Brimelow tutorials on the subject.

      • sing2gather

        Ok sorry for the previous question. I’ve found the catalog.xml and the library.swf when I extract the .ane so I made the library.swc by myself.

  11. arx

    Hi – I followed your described steps but all I get is:
    GCMPushInterface: registered Status Listeners (with your Sender ID and with my own).
    The packed apk works fine – but if I try to rebuild the app – I dont get ahead.
    (I use Flash Builder 4.6 – embed ANE etc. really simple)

    • afterisktech

      You can’t embed ANE it must be added by adt when you are creating apk. I’m not entirely familiar with the way FB is building apks. Try and use “adt” with command line instead? It is hard to pinpoint the problem at this point…

      • afterisktech

        Your default xml build file from fb 6 probably does not have those permissions that are needed to send and receive messages (including registration), you need to specify for your compiler/builder to use my descriptor or your own with permissions set but not the default one.

  12. Michael

    Hi there,

    Thanks for the Tutorial. Has been really helpful so far 🙂 I’ve just made a test app now and I’m curious if the notifications are supposed to be able to come through while the app is in the Foreground? Cause while the App is the background then the GCMPushInterface Code is “message” and the onMessage event fires fine, but when the App is the Foreground the GCMPushInterface Code is “foregroundMessage” and then no event handlers are fired? Is this intended? Or is there something I’m missing in order to get the message when the app is sitting in the foreground?

    Thanks in advance,

    • afterisktech

      Glad to hear you got it all working, Michael! In this version it is intended not to send any events to AIR if the application that employs this extension is in the foreground.

      • Michael

        Thanks for the reply 🙂

        Was there a specific reason for this if I may ask? Is it not a simple case of just providing an event handler that I could hook in on my side? I ask cause if I think of the case with an app like Whatsapp, you would want the notifications to come through both when you’re in the foreground and the background?

        • afterisktech

          The reason is that this extension was initially used in the app that relies on polling, because it does not require instant user to user communication, and event handling was tied into some view switching which basically was an undesirable behavior when user is actively using the application. If you can wait a couple of days I can find time and modify it so that system notifications are only sent when its in the background but the event will fire every time.

  13. Michael

    That’d be great thanks! Maybe if it just fires the GCMEvent.MESSAGE event every time and perhaps within the GCMEvent you could specify whether it was a foreground or background message?

    • afterisktech

      You dont’ need that as part of event. You can track this within your app using:

      NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
      NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);

      first is when app comes into foreground and vice versa.

      • Michael

        Thanks a lot. Appreciate it! Has the download link been updated? Cause I see the Last Modified date of the ane was 26 September 2012?

  14. MIke

    I see to be having the same problem as other had, I took the sample as file and create a class.
    the : private function handleRegistered(e:GCMEvent):void

    Never gets call I tried it with my key and the one supplied in the demo, same results. I also have my phone set to 3g and turn off wifi just in case it was a router port issue.

    I read all the post and made sure I didn’t have .debug prefex in my config file, made sure my section was correct.
    so at this point a little lost, it seems this works so it must be me 🙁
    below is my trace:

    Initializing GCMPushInterface…
    GCMPushInterface: registered Status Listeners

    Registering device with GCM…
    GCMRegistrar: registering sender AIzaSyBVnw2cch…..V80tTgOTmk

    this is far as I get…
    any help would be great.

    • MIke

      Well at lest now I’m getting a error code:
      GCMPushInterface Status: INVALID_SENDER
      GCMPushInterface Code: error
      can someone point me in the right direction?

      • MIke

        Hi Fabiano,
        what my main problem was two fold:
        1: I was using the wrong GCM_SENDER_ID. I was using the Google API key which is incorrect. What I needed to use was the Google project ID.
        2: I needed to fixed my app_XML file I had some minor mistakes in that.

        Once I corrected those two things all worked..

      • Fabiano

        Mike, thanks for your response.
        I saw that your GCM_SENDER_ID was “weird”. Anyway in my case I am using the correct one, I think that I might be missing some details in the configuration file.
        I will give it another try.

  15. MIke

    I got everything working and I’m getting the messages however the alert bar on top of the phone is not
    showing up?

    below is what I sending to the server :

    “registration_ids”: [
    “APA91bG2rc…DsPIJVG7t-rU2iqg”= ],
    “data”: {
    “alert”: “Alert Text!”,
    “type”: “my type Message”,
    “id”: “Id Message”

    and here is what is begin trace in my app:
    app was invoked from GCM notification
    type:my type Message,id:Id Message

    is there something else I forgot do setup to get the alert to happen when my app is in the background/foreground??


    • afterisktech

      Hmm no, maybe its your in the phone settings? It should automatically show, unless your app is in the foreground. Try to perform a test when the app is closed for sure (use task manager on the phone to remove task of your app)

      • MIke

        Thanks for your reply, I got it to work!. I want to Thank you for sharing this library very nice work.
        I’m only having one problem right now which is not major, when the alert comes up there is no default sound…

        I did have a problem were the app would crash it a notification was sent and the app was in the background, but I think I have fixed that..

        thanks again.

  16. afterisktech

    No problem, Mike! I’m glad you got it running. As far as sound settings go, I did not implement it in this version. It is defaulted to your system settings. Somebody else already asked about it, I need to set some time aside and update the library…

  17. w4ckos

    Hi guys. I’m trying to change the default icon into the ANE file…I converted it into a zip file…modified all icons…now I need to rebuild the new ane with APT Tool, but I don’t know the syntax. Someone can help me?

    Do you know the correct command? thanks

    • afterisktech

      Here is what I use:

      “$ADT” -package -storetype PKCS12 -keystore ./${CERT_NAME} -storepass ${CERT_PASS} -tsa none -target ane ../ane/${ANE_NAME} ../ane/build/extension.xml -swc ../ane/build/*.swc -platform Android-ARM -C ../ane/build/Android-ARM/

      Stuff in curly brackets needs to be replaced with your own values, paths might need updates too, for more info on ADT please refer to adobe docs.
      I hope this helps!

  18. w4ckos

    Thank you but I resolved with this on MAC….. /Users/*******/AdobeAIRSDK/bin/adt -package -target ane gcm.ane extension.xml -swc extension.swc -platform Android-ARM -C android . … It works! 🙂

  19. marius

    I tried to setup the demo in Flash Builder. This is the export of the project
    I do not get past the registration, nor any handlers are called. This is the only output:
    GCMPushInterface: registered Status Listeners
    GCMRegistrar: registering sender 1533xxxxxxx
    I think it is a config file issue. But I do not see it. Can you help me?
    Will you release the .java source files too? 🙂

    PS: I tried the native GCM demo from google and I receive the notifications, so its not an port problem.

  20. marius

    nothing happens after
    GCMPushInterface: registered Status Listeners
    GCMRegistrar: registering sender xxxxxxxxxxxxx
    I’m building it in Flash Builder.

    tho ur apk works flawlessly

    • afterisktech

      Sorry I do not use Flash Builder, so i don’t have an experience with publishing in that IDE. Check configs carefully, thats the first thing that breaks did you try to rebuild apk from sources in zip file?

      • marius

        I just realized if I install the release build of my app it works :D.
        but how do you make it work in debug mode? where should I add “debug” in the manifest file? .debug? or -debug?

        • Michael

          My ID is as follows

          In the Application Description under your android manifestAddtions section

          and under the intent filter

          That’s what has worked for me.

  21. Nikolay Nankov

    Hey, nice extension!

    I have extracted the .jar frome the .ane to change the icon but adt gives me the following error after trying to build it again: “java.lang.IllegalArgumentException: Paths beginning with META-INF/ are reserved:”

    here is the command line: adt -package -target ane gcm.ane extension.xml -swc gcm.swc -platform Android-ARM -C android .
    Any ideas?

    • afterisktech

      “$ADT” -package -storetype PKCS12 -keystore ./${CERT_NAME} -storepass ${CERT_PASS} -tsa none
      -target ane
      -swc ../ane/build/*.swc
      -platform Android-ARM
      -C ../ane/build/Android-ARM/ .

      You are missing a bunch of things, please check the above. That is my adt command. Stuff in {} is what you would need to replace with your own values as well as paths (if those are different for you). Hope that helps.

  22. Miranda

    So this is working well for the most part, but I noticed that, whether I open the app from the notification or just from the normal icon, it treats it as if I’m opening from the notification. Is there a way to distinguish between the two so that the “from notification” behavior isn’t necessarily used when there’s a notification but I don’t click it?

    • Miranda

      Also, you could theoretically get multiple notifications. I’m not sure if we did something wrong, but I just triggered two notifications for our app and only the first was showing in the Android notification pane (but the second will be what gets loaded right now, since _payload gets written over). Is this just how Android works, or did something get messed up? If multiple should be able to show, then knowing which they clicked would be helpful. If not, I feel like showing the most recent would be better than showing the first….

      • Miranda

        Edit: Nevermind on it not showing the latest, apparently I’m crazy….

        Is there a way to not show *only* the latest?

        • afterisktech

          “type” and “id” are parts of payload sent to flash. you can check them if they are null or not, although i don’t entirely understand why are you having this problem…

        • afterisktech

          It does make sense. I don’t think I’ve experienced that, or perhaps I never noticed. It is weird though because payload is only added to notification intent therefore it shouldn’t be available when clicking on icon, unless that is the same thing to android!

    • afterisktech

      There is no way, side effect of the icon is that when you launch the app from it it doesn’t carry additional payload, that notification does. You can distinguish by that.

      • Miranda

        Hmmm yeah it’s definitely only showing one notification for me. Does anyone know if this is a setting anywhere? Granted, there doesn’t seem to be a way to tell which notification triggered the event anyway, is there?

      • Miranda

        Argh, wish I could edit comments. Anyway, how can I determine what the additional payload is? I don’t see a parameter on the invoke event or anything. Thanks!

      • Miranda

        I don’t understand or we’re having a miscommunication. Type and Id are set when you receive the notification. This means that whether you click the icon or the notification, you get an invoke event and payload (with type and id) were set when you got the notification. So the app treats it like you clicked the notification either way. Which is great if you *did* click the notification…but if you click the icon (NOT the notification) and just want it to go to the home page or whatever, there doesn’t appear to be a way to know that you didn’t click the notification. Does that make sense?

      • Miranda

        The intent is set while the app is still minimized, according to my logging (meaning, I receive GCMEvent.MESSAGE while the app is minimized). It seems to get set right when my device receives the notification, rather than having anything to do with being invoked.

      • Miranda

        I never got a response to this post, so thought I’d try again:

        “The intent is set while the app is still minimized, according to my logging (meaning, I receive GCMEvent.MESSAGE while the app is minimized). It seems to get set right when my device receives the notification, rather than having anything to do with being invoked.”

  23. Miranda

    We’re running into an issue. Basically, it seems (after a little research) that the Kindle Fire doesn’t support GCM. Which means we wouldn’t get notifications via this ANE, which is fine. But currently with this ANE loaded, it’s preventing proper start-up on the Kindle Fire, where I think it should just ignore behavior or something such that our game will continue running and we just won’t receive any notifications.

      • Miranda

        I forget what shows for a non-registered device and only have one device locally to test with…will it always be non-null? And maybe I just need to watch for null and treat that as the initialize having been completed? (Right now we have an init callback that is called in handleRegistrationIDReceived or handleError.)

      • Roman

        I have the same issue on Sony Ericsson XPeria pro mobile where response string is empty after sending _gcmi.register
        Does anyone have any ideas how to fix it?

  24. Miranda

    I’m trying to figure out how to rebuild the ANE after replacing the notify icons. I converted the .ane to a .zip, unzipped it, and replaced the icons. But I can’t figure out how to turn it back into an ane. For starters, your first comment on the subject said to delete “library.swf”, but there are two of them. Delete both?

    Second, looking at your build command, I see a lot of the “build” folder…I definitely have no such folder, nor do I have any .swc files, which you also seem to use. My zip consists of:
    META-INF (folder)
    >ANE (folder)
    >>Android-ARM (folder)
    >>>res (folder)
    >>>>four “drawable-xxxx” folders, with the notify.png icons and some with other icons inside them
    mimetype (opening in a text editor gives the following contents without the quotes: “application/vnd.adobe.air-native-extension-package+zip”)

    Does your described method maybe not work on Windows? This machine is Vista, but I also have access to Windows 7 if you think that might be different.

    Lastly, I would think the certificate for the ANE should be your’s rather than the one for our project…it’s fine to swap it out?

    • afterisktech

      I mentioned that my paths are not to copy blindly. As far as making ane from jar, this has been described in this thread (partially), other info can be found elsewhere online. I don’t use windows sorry, I was not to provide support for any issue that can occur with extensions/building them/using them in general. Prior knowledge is required.

  25. Chris

    Here’s how I solved the icon problem on Windows. The instructions above helped but were incomplete.

    * Rename gcm.ane to and extract it to a directory named “gcm_ext”
    * Replace the icon images in gcm_ext/META-INF/ANE/Android-ARM/res with your own.
    * Inside “gcm_ext”, take “library.swf” and “catalog.xml”, add them to a folder, zip up this folder, and rename it to “gcm.swc”.
    * Run the following command from the directory where you extracted the originalANE to (note your path to the adt tool may vary):
    adt -package -target ane gcm.ane gcm_extMETA-INFANEextension.xml -swc gcm_extgcm.swc -platform Android-ARM -C gcm_extMETA-INFANEAndroid-ARM .

    Note the “.” at the end of that command, it is important.

    You should now have a new gcm.ane file at the root with the proper notification icons.

    • Miranda

      Sweet! I’m on other tasks right now, but I’m gonna be optimistic that your method will do the trick. 😉 Thanks!

    • N@ulet

      I think there is a simplier way to modify the icons. I just opened the ane file as a zip file (with winrar, without renaming the ane). I extracted the icons, modified them and replaced the original icons directly into the ane file (with winrar). It seems to work perfectly

  26. Pingback: A/N* – Flash, Flex, Actionscript, RIA blog» Blog Archive » Google Cloud Notifications – native extension for air on android
  27. Frank

    First of all, great to see an ANE that is actually working! Good job!
    But you seriously need to add that one needs to put “debug” in the manifest for the app to work properly in debug mode.
    Took me quite a while to figure that out. Guess I should have read the comments first… 😉

  28. Peter Goes

    Hi there,
    Awesome work on this ANE! Will you consider releasing the source code for the Java part on GitHub or something like that?
    The app is working flawlessly, no quiestion about it. But when a notification comes in, the main title of the notification says “Incomming Notification”, I was looking for a way to change that, but I guess that sting is somewhere in the Java files.
    Besides that, I think it is a great learning for me to have a look at the Java files to!

    Kind regards,

    • afterisktech

      I’ll consider that Peter! As far as “Incoming notification” goes, its because you’re not sending “title” to java” from your backend. Thats from the post:

      “title” – a title of message that shows in notification bar (optional).

      • Peter Goes

        Maybe I had a typo in my php array (I used the php file you provided). I will look into that as soon as I am back at my desk at work.

        But I do appreciate it if you could post the source! Maybe I could help you with further development or anything like that.

  29. Miranda

    Currently when we get a push notification it says “Incoming Notification” in the tray, is it possible to change that to custom text somehow?

    • afterisktech

      Someone posted a solution here. I don’t use windows unfortunately…but iIthink ADT utility is the same on both OS. Compiling this ANE is not different from compiling any other ANE. You can check tutorial Lee Brimelow made.

  30. hadi

    do you think you could give out the source java files also? it gotta be a great learning. cool extension by the way 🙂

  31. Roman

    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

    • afterisktech

      your parameters are wrong, refer to my php example. here is the list of those from php file:

      $fields = array(
      ‘registration_ids’ => $registration_ids,
      ‘data’ => $message,

      $headers = array(
      ‘Authorization: key=’ . $this->key,
      ‘Content-Type: application/json’

  32. JC

    Hello Afterisk, great ANE, thx you.
    I have an issue you may help with.
    When I send a Notif. just after Registration, my App. receives no Notification, while I got the “good” log: {“multicast_id”:5136328033319388942,”success”:1,”failure”:0,”canonical_ids”:0,”results”:[{“message_id”:”0:1357097224054858%82c4aab5f9fd7ecd”}]}

    And when I send another Notif. I have a “bad” log (and no Notif. neither of course):

    Do you see what could be the problem?

    • JC

      EDIT: something was wrong with the 2nd “sending”. So now I have 2 “good” log trace:

      but still with no notification on my device…
      I see inside App. the content of the Notification (with handlePayload and handleMessage), but I’m not sure what is actually responsible for the Notification display. (I use the App. in Foreground).

      Any help is welcome 🙂

      • JC

        Yes ok. I now “finally” get how it works. App. in background catches the Notif. properly and I now have to process the “foregroundMessage” event.
        Thank you for your answer and your great work Afterisk team.

        (btw, your app. SketchGuess is not available from France. Is it something you can fix or maybe it’s due to content language…)

  33. Jerrick

    Great tutorial! Ive been looking for something like this for days! After toying around for a couple hours i managed to get everything working in flash pro. I do have just one question, i noticed that when i recieve the push notifications in my app the icon for your game pops up.. is there anything i can do to change that? Again, thank you so much for sharing! You saved me a lot of time

    Any info is greatly appreciated.

    • afterisktech

      You are welcome, Jerrick!

      As far as icons go: You need to unpack .ane then .jar in it there you’ll be able to change icons. There are detailed posts on the subject in this thread, by some other users.

  34. Jerrick

    Thanks for the quick response. got icons working, notifications are sending, i’m receiving the payload in my app and now the last touch is vibration/led on incoming notification. I added permission for VIBRATE on the manifest but that doesn’t seem to be enough. is there a vibrate feature built into this or do i need to go get a seperate ANE for that?


  35. Siim

    First of all thanks for the effort you have put in making this extension.

    I have built project using example project and i don`t get any response from “Registering”.
    I have read through all the comments above, but still i cant find anything wrong with my setup. One thing i have noticed is that in manifest file there is:
    What is reported missing when compiling an apk. I have included ane and swc(renamed ane to swc) in my build. Ane File does not have extension named like that. Am i missing something ?

  36. Mike

    Well done on the extension. I have it all hooked in and working, however I’d like to modify some of the as3 API in, however the as3 code is not available. I would love to help add to your ANE with some more functionality. Feel free to email me about it. Thanks!

  37. ko1isko

    Hi, thank you for great ane. I do probably something wrong I cant get it work. I tried to build the example in FB6 and run on Android device. I can see the app. In log is GCMRegistrar: registering sender 863211319405. But handler is not executed. I dont know what is wrong. Can you help me please? Thank you.

    • afterisktech

      Sorry for delay, I was out on vacation. Hard to help, but i’d start with checking your configs if you wrote new ones. Handler not executing usually means, your ane is not properly attached to .apk and is malfunctioning…You can scan this thread, it was a common error for many folks.

      • vedder69

        hello Marius,
        thanks for your answer. I have try your FXP and change the config with my id and it doesn’t work.
        My ID is and not begin with “air”, i use the AIR 3.1 SDK.

      • vedder69

        here is the problem : when i release with your appId it works and when i want to use my app id , it doesn’t work !

      • vedder69

        update : my application id is usually : , when i do this , it doesn’t work, no register, but when i write com.mysociety.myapplication, my application register but i don’t receive notifications.

        • afterisktech

          if you’re talking about permissions and intent-filters, you need to add “air.” because thats what your package really is. ie “” or ” com.mysociety.myapplication”

      • vedder69

        I don’t talk about permissions and intent-filters. my package id is like when i set the application id like that : com.mysociety.myapplication it works and when i set it like that : it doesnt work . Can you helop me please ?

  38. marius

    is there any way this can compiled so flash builder won’t show that error when I try to run in on the desktop in the air simulator?
    tried to add this “-platform default -C default .” when repackaging with the new icons and I got the
    “Unexpected implementation for platform: default” error

  39. Pitkin

    Hi afterisktech. Good work!
    Can you help me, please.
    The message send by server with php code below, show always in the
    private function handleMessage (e: GCMEvent): void {
    _payload = e.message;
    GCM payload received: type: null, id: null.

    php code:

    $ message = array (“title” => ‘title’, “alert” => “created a new sketch!”, “type” => “sketch_created”, “id” => ‘id’);

    $ fields = array (
    “Registration_ids” => $ registration_ids,
    “Data” => $ message);
    $ headers = array (
    ‘Authorization: key =’. $ apiKey,
    ‘Content-Type: application / json’
    In what could be the problem?
    Please, help to fix it.

    • afterisktech

      you are using curly quotations. use signle quotations or regular double ones everywhere, also dunno if it matters but don’t capitalize “Registration_ids” and “Data” field names.

  40. nick

    Can someone please post an example of the PHP code, the sample provided is not helpful for a non PHP person

    many thanks

    • nick

      ok i have the php code kind of working but in the app i am only getting returned type and id, no title and no alert
      $message = array(‘title’ => ‘Sketch Guess’, ‘alert’ => ‘ created a new sketch!’, ‘type’ => ‘sketch_created’, ‘id’ => ‘12345’);

    • afterisktech

      its not very hard you need to unpack the extension and jar and add your own icons, unfortunately there is no easier way for now but people in this thread did it many times. I’m working on a 2nd version now that’ll allow adding icons via as3 init as bitmaps

  41. phihochzwei

    I tried to put this in my project, but once my app starts I only get:

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

    I am using FB 4.6, included the ANE in the Manifest and also did as recommended (copy and rename to swc )

    Anyone an idea ?

    • phihochzwei

      Just found it myself.

      You not only have to add the ANE to your project. You also have to add the ANE in the packaging settings manually. Personally I think, this is weird, since EVERY OTHER FREAKING file will be included automatically. But hey, Adobe surely will know what they do…..

      • afterisktech

        ok if you renamed swc and killed an ane it won’t compile, swc was just for older IDEs to not throw compile error. Nowadays, and I think that includes new FB versions just ANE is sufficient. Maybe you needed to change the type of the library? In Intellij you can specify “ANE” type, and it’ll get added when creating .apk

  42. Pingback: First free Facebook Single Sign-On (SSO) Adobe AIR native extension for Android | Priorisk
  43. Eric

    i change icon in the res folder , now i want to rebuild ane, how to use ADT Tool to rebuild,have tutorial?
    sorry my english so bad.

  44. anderson

    VerifyError: Error #1014: Class com.afterisk.shared.ane.lib::GCMPushInterface could not be found. where is shared??!

  45. Berat

    I tried your ane on Galaxy S3(Android 4.1.2) it is registered succesfully, but when i tried it on Xperia Arc S(Android 2.3.4) it writes Registering but no effect after that. Events are not triggered. Do you know the reason?

    Thank you.

  46. Berat

    I read that you were busy and couldn’t add sound to ane. Did you add it for now? Or do you think make your project open source?


  47. ram

    SRY my text didn’t appear .
    What i mean that in our app.xml where we add permission to c2dm we have to add: android:name=”” android:protectionLevel=”signature”
    uses-permission android:name=””
    category android:name=””

    On release apk we should remove .debug

  48. Brad Patterson

    I do not get any Notifications at all. I have worked on this for hours, and have gone through the entire tutorial 3 times just to make sure I haven’t skipped anything.
    The app will register and send back a ResigrationID. I send a message out through php and google sends back a success:1, failure:0 in the return json.
    The device does nothing. No text in the _messageField, nothing on the device itself.
    I am using a Samsung Galaxy 10.1. I am sure the issue is something I am doing wrong, but for the life of me I can’t figure it out.
    Like I said, everything seems to work, but the actual Notification on the device.

      • Brad Patterson

        the last output in LogCat is…
        GCMPushInterface Code: registered
        It looks like it registered.
        I am using my google API Project Number as the Sender ID, I could not find a sender ID anywhere and I found online that it is now Project Number. Compiling with Air 3.6.
        Google Cloud Messaging For Android is turned on in the Services.

        • afterisktech

          sender id is displayed in your google play publishing admin, when you’re looking at the app details you can click at “Services & APIs” and it will be displayed as “Linked sender id”.

      • Brad Patterson

        I have tried everything. I just don’t receive any notifications at all. Everything else seems to be working fine.
        Did a lot of searching and google uses project id not sender id.
        Does this app have to be installed through the google play for it to receive messages? or can it be installed like a normal debug apk through terminal? Is my problem not going through Google Play?

        • afterisktech

          it doesn’t have to be installed through google play, but it has to be registered on google play and you must use correct sender id and package name. its a common error to apply wrong package or id.

  49. Florian Matoflink

    As many people here, my GCMEvent.REGISTERED is never fired. I think i tried every solution in the previous comments so my manifest should be ok. I hope someone has an idea and I post my manifest.
    Thank you very much.
    ( air.TestMobile )

  50. John Clarkson

    Thank you, worked perfectly. I have one issue where the debug trace shows that I receive the Remote Notification on my Samsung S3 (Android 4.1.2) for *every* push that I send, but I do not always see the icon in the notification bar. Has anyone else had this problem?

    Aside: Our project is also used on desktop and iOS (with different ANE for remote notifications). Rather than using conditional compilation etc I created a default actionscript only version of the library.swf that just implements the GCMPushInterface and GCMEvent interfaces and compiled it into the ANE (e.g. the last part of this command: adt -package -target ane gcm.ane extension.xml -swc extension.swc -platform Android-ARM -C android . -platform default -C default library.swf). I found (painfully) that to package a default implementation for iOS I had to be using an AIR SDK later than 3.4.

  51. saint

    Hi, guys, respect for your great work.
    How about including sounds and vibration to the ANE… any thoughts about that?

  52. Pingback: AIR Native Extensions Collection
    • afterisktech

      this interface has capability to unregister, but it can’t unregister when you just uninstall. call unregister before they quit and re-register again on every app launch. thats how you can do it.

  53. moon

    When I user this ane on motorola x911,It traces GCMRegistrar: registering sender 1012537563378 but Events are not triggered.When I add .debug after <permission android:name="air.MobileLHNOVA. It logs still GCMRegistrar: registering sender 1012537563378 ,no other messages , Do you know the reason ? Thank you!
    I use exzample apk it can get id from gcm,if i change my projectid and rebuild it ,it still says GCMRegistrar: registering sender 1012537563378

    • afterisktech

      try to see what your php (if you are using php) code says, see if delivery fails, see if you have any registered devices in your db (if you are using it), the sende you’re posting here. is it yours? i just checked the sender id you provided…it’s not ours…debug sender code.

      • ogy

        FATAL EXCEPTION: IntentService[GCMIntentService-DynamicSenderIds-1]
        at com.adobe.fre.FREContext.dispatchStatusEventAsync(Native Method)
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(

      • ogy

        i have permission for this but still in logcat:
        Permission Denial: receiving Intent { cat=[] flg=0x10 (has extras) } to requires due to sender (uid 10040)
        still the notification is ok but without sound and if app is in background has fatal errror

      • ogy

        Can i make that the notification still come when the app is in background just like when the app is not running?

  54. temp89

    thanks sir for this amazing library
    but i don’t get any registration ID
    i’ve added .debug since i’m debugging
    but i get nothing
    what could be the problem?

    • afterisktech

      There could be a thousand reasons why it happens. You can start debugging by creating the new app (for testing) with the same package id and use the same sender id. if it works you need to find a reason in your own app.

  55. Stephan Müller

    hi there, first of all: thanks for the extension! unfortunately i’m having problems receiving push messages, using urban airship to deliver test messages (debug mode on).
    here’s what i did:
    1. obtained a sender id via google (157978887xxx – last three digits replaced with an x); note: i haven’t uploaded an APK to google before, i just created the entry for being able to enable GCM for it and getting the sender id.
    2. used the same code as yours
    3. changed permissions in application xml (my app package name is com.skizzo.redar), it looks like this:
    the result is only the call of the function “register” (which is done after initializing the CGMPushInterface object), but there is nothing like “registrationID” in the response text, so the whole block in the end of the register function is not being called..
    thanks for your help!
    – stephan

  56. Skizzo

    Hi and first of all: Thanks for your extension! Unfortunately, I can’t get it to work. If it’s okay, I post the steps I did, and hope some of you gurus can help me! 🙂
    1. Added an app in the Google Developer Console (in my case, the only thing i really entered is the name of the app, which is “redar”). Since I simply want to test if GCM is working on my Android smartphone, I did not upload an .APK yet.
    2. Got myself a Sender ID (In my case, 157978887xxx, where x is a 1-digit-number I don’t want to publish here)
    3. Used the code you posted and used the obtained Sender ID as GCM_SENDER_ID.
    4. Edited my app xml (package id: com.skizzo.redar), it now looks like this (please see:
    5. Registered on
    6. Added an app on, named “redar”, set the mode to debug mode.
    7. Added the GCM service, package name = “com.skizzo.redar”, API key = The same key I used for obtaining my Sender ID.
    8. Launched the app.
    In the function register(), I get the following response string:
    GCMRegistrar: registering sender 157978887xxx
    (x is again a 1-digit-number I don’t want to publish here)
    Since you’re checking the response for the index of “registrationID:” which can’t be found in the response, the functions handleRegistrationIDReceived etc. are not called. Furthermore, no GCMEvent event handler is ever called..
    Could you please help me? What am I doing wrong? Is it because I didn’t upload an APK? Could there be something wrong with the app xml?
    Thanks a mill!

  57. kimus

    Hi! The extension works well, I can get the “registrationId”, however, I need to send this Id to urban airship API (api/apids/), and they need a version 4 UUIDs (36 characters long) of this id…….. but the Id that I receive from your extension is really longer than 36 chars… any ideas ? thanks !

    • Skizzo

      how exactly would you send your registrationID (mine is 162 digits long) to urban airship? the function “handleRegistrationIDReceived” is empty except the comment..

      • kimus

        Thanks again for your Answer it helped me dig a little deepter. From what I understand now, UrbanAirship expect an “ApId” OF THEIR OWN in their back-end “api/apids” call. They probably bas this “APID” on the 162 digits registrationId given in the GCM SDK … This “APID” would actually be available only from the JavaLib they give to code a JavaClient. So, for now, my conclusion is that, for Android devices, if we are using UrbanAirship as a back-end service, we would need a NativeExtension for Air that exposes the UrbanAirship Java Lib.
        We can see here that the registrationId from GCM is a different property than the “APID”:

        • afterisktech

          yes, like i said they have their own system, a mediator between platform and your client…so yeah either use the extension for airship or just make your own backend. Its rather simple. The php example is included with my blog post.

      • Skizzo

        thanks kimus, but does that subsequently mean that there is no way to use the extension provided in this tutorial in combination with urban airship and android?

  58. kimus

    From what I understand, yes, we can’t use this extension if we need to connect with UrbanAirship. It’s really disapointing cause I installed and used your extension for iOS and it worked perfectly.
    I did contact support for UrbanAirship, and they confirm that we need to user their Native Javalib extension. 🙁 🙁

      • afterisktech

        unfortunatelly this extension is written for GCM not for urban airship service…urban airship requires a different sdk to use…you may also try and use your own backend like we and a lot of other people do, it’s not that complicated…the only problem is you’ll need to have your own hosting…

  59. airmobileAndrius

    Hello, thanks allot for an amazing library 😉 Some of you experienced an issue that app crashes if notification comes when app is running. I’m wondering if anyone solved that problem, if so how? Looks like I did everything correctly because I can receive notifications without problems when app isn’t running.
    The other small issue is that notifications come without sound. Is it somehow possible to make the default sound to play when notification is received?
    Thanks allot in advance 🙂

  60. Jerry Hamby

    I hope someone can help, I’m not getting any data when my app receives the COMING_FROM_NOTIFICATION event.
    I can get the GCM token OK, but when the Push service I’m using sends a message, the data is empty.
    Have you send this issue or have suggests?

      • Jerry Hamby

        Here is the problem I’m seeing when I get a notification:
        D/c2dmBdcastRcvr(3934): Broadcast receiver started!!!!!
        D/c2dmBdcastRcvr(3934): bitmap null
        W/GTalkService(760): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { pkg=air.pushpop (has extras) }
        I/air.pushpop(3934): Push notification is supported
        I/air.pushpop(3934): [PushNotification Error] cannot parse the params string
        (There is no data for the ANE to parse)

        Why is this happening?

  61. raduanastase

    I used the demo with my own GCM sender ID with my nexus s (4.2.2) and it worked fine, i then tried it with my Samsung Galaxy Tab 2 (4.0.3) and nothing. After that i tried it with my friend’s Samsung Galaxy S 2 (4.0.4) and again, nothing (it stops at “registering sender …”). I also mention that i tried all of these devices with the original demo code and GCM sender ID and obtained the same results.

    I tried putting “air.” in front of my app id but again, nothing.

    I put here the xml .

    Maybe, when you have time, you could tell me what I’m doing wrong.


      • raduanastase

        You were right.
        Although it is mentioned in the comments something about debug version I didn’t thought that I should build a release version for testing. So that was my problem, on Nexus S it worked also in debug mode, but on other devices it worked only in release build. So my advice to anyone who tries to communicate with GCM with this ANE or other ANEs, please, for the love of Android, work on the release build 🙂

  62. Jerry Hamby

    I’m doing a test with my push notification provider and have an issue with the ANE:
    I send the provider this JSON object:
    { “title”: “this is title”, “id”: “This is ID”, “type”: “This is type”, “message”: “message goes here”, “alert”: “This is a test alert” }

    The response object shown by your ANE:
    GCM IntentService class:
    Acquiring wakelock
    V/GCMBaseIntentService(8958): Intent service name: GCMIntentService-DynamicSenderIds-2
    I/air.air.pushpop(8958): GCMPushInterface Status: type:This is type,id:This is ID
    mHandleMessage e = [Event type=”GCMEvent.MESSAGE” bubbles=false cancelable=false eventPhase=2]
    mHandleMessage e.message = type:This is type,id:This is ID

    Why am I only receiving “type” and “id” and not any of the other properties?
    Need help please!

    • afterisktech

      hmm…hard to say, but if the part is received and part is missing, then i’d say data wasn’t parsed right. check your input? for example i see you’re using “ instead of regular double or single quotations…that’s just my guess…

  63. Amani S

    Your ANE works like a charm thank you.
    but there is an error that i’m facing
    when i turn off the mobile device and turn it on an alert pops up claiming that there was a problem and the app has stopped working.
    i’m sure its from this ANE, because i removed the ANE, turned off and on the mobile device no error, and even tried the app with the ANE on other devices same error..
    any suggestions? or is anyone facing the same thing?

    • afterisktech

      Maybe your device is running out of ram and it causes it to force-close the app. Not sure, since I’ve never seen such an issue (if anything it was just dropping my app all together, but without messaging of any kind)

  64. SteveCohen34

    Hi, i try for 2 days to make it work but it don’t want… I see i’m not only to have this problem but i’m the only to don’t find how to fix it…

    Nothing append after “Registring device with GCM…”

    To be sure to forget nothing in app.xml i paste your and modify for my app:

    To test it i use flash builder and actionscript but it pretty similary, see my View :

    All listeners are registered but Registered is never called…

    Do you know why ?

    ps: i use t-pad with android 4.0.4, i tried your app and work fine. I don’t know what i forgot…

  65. Victor Yew

    Hi, I have been scratching my head for a couple of days while all I get from the trace is “GCMRegistrar: registering sender XXXXXXX….” when I call this function _gcmi.register(GCM_SENDER_ID). Please help.

  66. Huggles

    Hey there!

    After quite a while I finally got your ANE working. (In a very basic form tho!)

    Now when I send a push notification, it instantly pops up on my device and all. The text, title etc can be set. But the Icon that pops with the push notification shows as the “question pencilmark” you used for one of your apps (and is referred to in the example code).

    Where do I change this? 🙂

    Thanks in advance!

  67. Luis Miguel


    First of all, I want to say that the title of this blog entry says exactly what this is, this is the only ANE that I’ve found (after making a profound search on the Web) that works with the GCM and it’s completely free! So, I must say thanks a lot for sharing it with everyone and good job.

    I, myself, have been struggling for a couple of weeks making my own ANE for this but I had problems exporting the Google APIs libraries required for the GCM to work within the Android native project. I’m not an Android developer myself so after trying (and failing) for sometime I decided to quit and search for an existing ANE that would help do the job, and guess what, this was the only one I found.

    Now, the reason I’m writing this is the following;
    I understand that your ANE was thought to get notifications specificly for your SketchGuess app, that’s why you are only sending the “type” and the “id” variables of the payload from the Android side to the extension through the StatusEvent.
    The thing is that in the application we are developing, we are interested in getting the hole payload or at least all the custom variables that we may add to it when the notification is sent from the server (this is what we are currently doing with iOS notifications so I supposed it’s possible).

    Now, I far as I understand, in order to achieve this behavior, the ANE should be (lightly) changed. Would you be willing to make a custom build of the ANE with such changes? I know this is asking a lot but you have no idea how incredibly helpful this would be.

    If this wouldn’t be possible, is the are a chance you could give me some advice on how to successfully export the native Android project to have it include the GCM libraries?

    I don’t usually ask for these kind of help but these are times of real need!

    Thank you beforehand!

    PS: I really enjoyed that LD28 entry I had some trouble understanding the use of the different elements at the beginning but in the Kongregate version is kind of neat, the game’s challenging but really good. We had the chance to participate too and this is what came out

    • afterisktech

      Well the idea behind GCM payload plugins (unless catered to something particular) is that you would create value pairs, assign them to one field and then parse in client, because they come as a bunch of strings anyway, the payload does not support objects or datatypes other then string. That is true not only for this plugin but for anything that uses push GCM/APN etc.

  68. Hakko

    Hi! Thanks for making this publicly available for everyone to use! I’ve created a test app in Flash CC, ran the debug version on my phone. I also managed to get the php side working, and the messages are received when the app is active or running in the background. When the app is closed however, the messages don’t come in. No notification at all.

    Does the app need to be in the Play Store for Google to know which phone to target or something? I think I’m missing something here..

      • Hakko

        Thanks for the swift reply.
        I’ve uploaded the app to G Play and published an Alpha version. But still no notifications when the application is closed..
        The app doesn’t fetch them when opening later on either. It does receive messages send when the app is opened.

        Logcat shows nothing

        • afterisktech

          No problem. Hmm…this is rather odd, and I don’t think I’ve encountered such issue or question here before. The only thing i can think of is that you unregister the id before quitting. By app opened you mean app is active but in the background?

      • Hakko

        Alright. I’ve looked at the trace outputs and it shows no unregistration before closing the application. When I open the app again it registers automatically, after which it does say the device was already registered.

        By app opened I meant open in the foreground. The app UI is visible, and I can see the message coming in in the textfield. The text shown is:

        GCMPushInterface Status: type:null,id:null
        GCMPushInterface Code: foregroundMessage
        GCMPushInterface Status: type:null,id:null
        GCMPushInterface Code: message
        app is in the background: adding GCM app invoke listener
        app was invoked by gcm notification

        OH wait. scratch that. Just closed the app, and tried sending the message and I got a notification! /
        hmm.. but only one time. On the second try no notification was received. I’ll just go on and try some things. It worked once, so I guess the code should be good right..?

      • Hakko

        Ok, I’m getting the notifications now. I had to install the app from the Play store, not the APK directly I guess.
        Only thing now is that it’s a quiet notification. No sound, no vibrations, no led. Is this by design, or do I need to add something to the php code?


        • afterisktech

          It doesn’t create notifications when app is in foreground. no point right? What it does instead is sending “foreground message” event directly to air client. So you can still handle if someone or your backend sends you something.

        • afterisktech

          sound and vibrations are set to default of the phone current state. the LED was never considered. if you need to update your icon you can unpack jar and replace it then repack it. (see comments, people did it before)

  69. Claus

    Hi guys, although problems have been numerous and solutions probably too, I just came across some strange behaviour when testing this ANE in both debug and release modes.
    In debug build, I had to use the API key for server applications, which is a long string of numbers and letters e.g. AIzaLaNgeDadleR2014sAAdan89deRfoRAVGGILDt
    In release build, I, much to my surprise, had to use my project ID. Otherwise it would never get past the ‘Registering device with GCM’ message !
    Just to let you know if you run in to similar problems.
    If anyone can explain this, please, I am all ears !
    Cheers, CK

  70. Claus

    How about that sound and vibrations – has anyone got that working ? On both my devices, it is a completely quiet notification, eventhough they are both set up to play a sound and vibrate on notifications…
    And, as Ogy has mentioned, it crashes the app when it is in background on one of my devices running Android 4.0.3. On my HTC Desire, running Android 2.2, it works as it should (no sounds though).
    Here is a bit of the logcat:
    threadid=17: thread exiting with uncaught exception (group=0x4186c1f8)
    FATAL EXCEPTION: IntentService[GCMIntentService-DynamicSenderIds-2]
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(

    Cheers, CK

    • Claus

      So continuing down the troubleshooting path, line # 123, which apparently is failing, has the following code:
      ActivityManager activityManager = (ActivityManager)context.getSystemService(“activity”);
      Judging from the exception, it must mean that ‘context’ is null ? Could you add a check and return false from the isAppInForeground-method if context is null ?
      I honestly don’t know why it is failing on Android 4.3.7 and not on 2.2…
      Cheers, CK

    • afterisktech

      They work with default settings of the system, if you have sound there should be sound otherwise no, same for vibrations. Sorry, I did not have time more time to spend on it. It was a gesture of good will, then other things kick in. I provide reasonable support but some of it is just beyond reach.

      • Claus

        Hi, thank you for your swift reply. I fully understand that supporting this for all eternity simply is too much. I will try to debug this a little further and post my findings here. Good will indeed, it is much appreciated, rest assured. Thanks, cheers, CK

      • Claus

        Hi again, sorry it took a while… I read somewhere that waking an app with a notification required the app to register for this particular kind of behaviour in the OS on first run. This change in requirement was introduced in Android 3.1, which explains why it worked on my phone running v2.2 and not on my tablet running 4.0.3.
        Long story short, I added the flag so the app tells the OS to wake it even if it is stopped when a notification for the app is received. I also have fixed the null pointer exception (at least it seems so) as well as added default sound, led-light flashes and vibration upon notification. In our test suites it has worked well so far. Would you like to host the modified ANE ?
        Thanks again, cheers, CK

  71. sudoplz

    Hey man, I’ve set up your ane, register just fine so far so good.
    When I send a (custom JSON) message from my push notification service (appcelerator cloud), eventhough I get a GCMEvent.MESSAGE dispatch, the message is type:null, id:null.
    The JSON I send is this: {
    “alert”: “Test alert”,
    “type”: “Test type”,
    “id”: “Test id”
    What am I doing wrong?

      • sudoplz

        Hmm, but isn’t the whole point to just receive a JSON with those 3 things inside? “alert”,“type”,“id”? If it receives a JSON with those 3 inside what difference does it make where it comes from?
        Perhaps I need to add something more in my JSON?

        • afterisktech

          sory sudoplz, i can’t give support for json or the custom push notifications. something is wrong before it gets into the app, why? i don’t know. try and use test php chunk to debug. if that works turn to your service see how you compose the json string…

  72. T-Macintosh

    I can’t understand the “Compile and run example application” part.
    I get the error “VerifyError: Error #1014: Class com.afterisk.shared.ane.lib::GCMPushInterface could not be found.” and I think the main reason is this part.
    can you tell me more specifically?

      • sudoplz

        2 things you might want to double check T-Macintosh.
        1. That the ane itself is being transfered INTO the device (for example in intellij, I have to add the ane itself, onto the assets that WILL be transfered into the device, from the module settings)
        2. That you’ve set the into your app xml, which I believe you have.

        Most probably your ane is not transfered in your device, therefore you’ve got an issue on runtime!

  73. Fabrice

    Hi there. First of all, thanks for your ANE. You make my day !
    Everything works like a charm !
    Everything but vibration and sound.
    Claus told us on 27 march 2014 that he did it works with some modification of your ANE. Is there an open source version of your great work ?
    Before posting, i’ve tried integrating com.adobe.VIBRATION ANE and consequent … Checking all my phones parameters about notification sounds and vibration……. and so on…….
    I did’nt get any vibration nor sound. :’-(
    I’m very interrested by your java code on this project and if there is a link (of your original work or of Claus’s work), i’ll be happy to get it. 😉
    There is another project ( with a very similar code… are you working on it ? if so, i’ll buy this ANE with more options…
    Best regards,

  74. Thiago Camargo

    Hi, I’ve used the ANE and it works fine, it’s really cool.
    However after adding the ANE my app is crashing when I try to run it in the simulator.
    As far as I’ve read online this happens because the ANE didn’t include the ‘default’ implementation.
    Is there a plan for that to be fixed or maybe the ANE source code made available so community could fix it?

  75. Rami

    Hey afterisktech,

    I am using your ane from last year and everything works fine but i need to add 2 new folders to android/res (drawable-xxhdpi and drawable-xxxhdpi). Can i add these two new folders ? do the icons added take effect on devices xxhdpi and xxxhdpi ?

    Plus the sizes of the icons in drawable-hdpi, drawable-ldpi, drawable-mdpi and drawable-xhdpi do not fit android forum example:

    for the folder drawable-mdpi your icon size is 24×24 however in the forum 48×48 is used. (baseline)
    for the folder drawable-hdpi your icon size is 36×36 however in the forum 72×72 is used.
    for the folder drawable-xdpi your icon size is 48×48 however in the forum 96×96 is used.

    for the folder drawable-ldpi, you normally don’t need to create custom assets at this size because Android effectively down-scales your HDPI assets by 1/2 to match the expected size.

    Find below Android forum about icon sizes:


  76. N@ulet

    As I’m french, does anyone have an idea to make characters with accent (àéè…) appear in the “alert” field?

  77. Mike Cheung

    For Sound and Viberation, I solved by adding code to

    Line 78
    notification.defaults |= Notification.DEFAULT_VIBRATE;
    notification.defaults |= Notification.DEFAULT_SOUND;

  78. Jevan

    I’m trying to make this example work with flash builder 4.6.
    I’m a new bee using flash builder. you explanation are greet but can get the app or your example working. Can you tell me more info how to make it work (e.g what to include, how to include the files). If you can provide a sample flash builder project file would be great.
    Thank You!

  79. Cellina

    Hi, @afterisktech
    I have worked for 1 day and can’t get the register id with trace the following result
    “GCMPushInterface: registered Status Listeners”
    “Registering device with GCM…” . This is my app.xml (, please give me some hint, thank you!

  80. sumeet kumar

    on using this method “_gcmi.register(GCM_SENDER_ID)” i am getting null as return…am i doing something wrong. Can you please guide.

    Thanks in advance

  81. Raman

    I’m trying to make this example work with flash cs6.
    Can you tell me more info how to change notification icon from Flash. If you can provide a sample Flash project file would be great.
    Thank You!

  82. Cosmin

    Hi, I have a few questions.
    1. Is there a chance for a client application to receive notifications dynamically from different servers, the servers which connects to?
    2. If so, how can you register to those servers?

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>