as3c2dm – AIR native extension to push notifications with C2DM
In this short video recording you will see my new and first AIR native extension (ANE) that I created for C2DM (Android Cloud to Device Messaging Framework).
C2DM allows you to push notifications to your Android applications. The cool thing about it is that your application doesn’t have to run in the background in order to receive messages. In this case, my ANE creates a notification with a specified ticker, title and text. When the user taps on the notification it runs an AIR application and passes the sent message text that is displayed in the app. Check out the magic for yourself in the video below.
The source code is available here. You can also download the packaged ANE and the C2DM Messanger app from here and here.
Check out some more already built ANE’s here.


[...] as3c2dm – AIR native extension to push notifications with C2DM at Space of Flex/AIR technologies. //Two words ‘VERY nice’ thanks for sharing, this will no doubt save one item on many peoples ‘todo list’ (smile) LD_AddCustomAttr("AdOpt", "1"); LD_AddCustomAttr("Origin", "other"); LD_AddCustomAttr("LangId", "1"); LD_AddCustomAttr("Autotag", "technology"); LD_AddCustomAttr("Tag", "android"); LD_AddCustomAttr("Tag", "flexairflash"); LD_AddSlot("wpcom_below_post"); LD_GetBids(); Like this:LikeBe the first to like this post. [...]
‘as3′ c2dm – AIR native extension to push notifications with C2DM at Space of Flex/AIR technologies « marcusjpotter
1 Oct 11 at 10:14 am
Is there a possibility to add the receive listening upon installation before user is running the application for the first time ?
Gadi
2 Oct 11 at 10:55 pm
@Gadi I don’t think so, at least not with current implementation in as3c2dm because before you can start using it you have register users phone and the application in c2dm service. This is done through AIR part of the app when the app receives back a registration event.
Piotr Walczyszyn
3 Oct 11 at 2:17 pm
[...] AS3C2DM Lets you create custom push notifications for your Android applications. [...]
AS32DM | Extensions for AIR
5 Oct 11 at 1:09 pm
Hi,
I have android jar that calls over JNI .so library. Now I want to add it in AIR app. However when I pack all together in AIR apk, it throws linkage exception. I unpacked APK and saw that .so shared libs are not there.
Any thoughts how can fix this problem?
Thanks,
Marin
Marin
5 Oct 11 at 2:31 pm
Dlaczego nie po polsku ….
Polski evangelista
prosimy o kilka tutoriali w polskim języku , łatwiej będzie nam co nieco zrozumieć
dziękuję (również w imieniu rodaków )
Pozdrawiam
Paweł
5 Oct 11 at 9:43 pm
Hi Piotr, i’ve signed for android c2dm and made a simple android app exactly like yours, the problem is that i don’t receive any notifications and i can’t register either and i’m assuming this is because the android manifest, can you please tell me what changes should i make here
yonodo
14 Oct 11 at 3:27 pm
@yonodo did you register your app id with air. prefix and .debug suffix?
Piotr Walczyszyn
14 Oct 11 at 5:14 pm
@Piotr: I’ve registered my app with com.dg.testapp
yonodo
15 Oct 11 at 12:43 pm
@yonodo you should register with air. prefix because this is what AIR runtime adds to your app id in the background. Also when you are running in the debug mode it adds .debug at the end of id, so you should register for both and Google C2DM registration form.
Piotr Walczyszyn
16 Oct 11 at 3:56 pm
Hi Piotr,
I downloaded as3c2dm-example.fxp, and tried to import to my 4.5 premium version flash builder. When I am importing, it shows java null pointer exception. Do you have any suggestions for that? Again, I tried to build my own project with the .ane file that you provided, but my flash builder can not recognize the com.riaspace.c2dm package.I need your suggestions.
Regards,
Nahid
Nahid
18 Oct 11 at 6:41 am
Hi, I’m trying to use this ANE as you are in your example but the c2dm.register method never dispatches a REGISTERED nor ERROR event.
Any clue?
Gilmar.
Gilmar
26 Oct 11 at 6:20 pm
@Gilmar I suspect that you have a mismatch of your application id and what you registered at google c2dm service registration form.
Remember that you have to register app id with air. prefix and .debug suffix if you are running in debug mode which you probably do during development.
p.
Piotr Walczyszyn
27 Oct 11 at 2:47 pm
Hi Piotr,
do you have an estimate how hard it would be to get iOS server based push to work?
We would need this shortly and maybe we could also sponsor the development for this…
or start learning objective-c
Best,
Cedric
Cedric Moschallski
28 Oct 11 at 4:20 pm
Hi,
I have just release a blog post about creating a NativeAlert extension for AIR. It includes multiple buttons and dispatches ActionScript events when the user selects one of those buttons.
the post can be found here.
http://www.liquid-photo.com/2011/10/28/native-extension-for-adobe-air-and-ios-101/
The source is on github and you can download the NativeAlert.ane file directly also
Hope you guys like it.
Anthony
30 Oct 11 at 1:05 am
Hi Piotr,
I am sorry that I could make my question clear to you. Just a simple question now. Is it possible to use ane file in 4.5 premium version flash builder. If yes then how?
Regards,
Nahid
Nahid
30 Oct 11 at 7:21 pm
Hi, Piotr!
I also am getting the Java Null Pointer exception when attempting to load or build the sample. Using Flash Builder 4.5 Premium on a Mac w Snow Leopard.
Thanks!
Pete
Pete
3 Nov 11 at 7:24 pm
Pete, I think the problem is that you are importing the project into FB 4.5, and the source files are updated for the 4.6 prerelease version.
Leonardo
4 Nov 11 at 8:36 am
Hi Piotr, many thanks for putting this together for the community, I cant tell many people will owe you one
I do have a problem getting all this figured and would like some assistance if possible.
Question 1) namespace used as registration for C2DM, say I desire to signup with com.company.product (which is my app home ns), according to your suggestion we should sign with 2 namespaces:
a) air.com.company.product (used for production environment).
b)air.com.company.product.debug (used for debugging in flex builder).
Leonardo
4 Nov 11 at 8:47 am
Question 2) What do we need to do to set this up in FB 4.5 ( I know the project was recently updated to 4.6 – prerelease – which offers a more nicely UI to do it).
I tried to figure it out by following this: http://blogs.adobe.com/actionscriptdocs/2011/10/using-flash-builder-4-5-1-to-compile-an-air-app-that-uses-a-native-extension.html
But that didnt help much. To accomplish step one from the native extension setup (above), what should it do?
Add this http://snipt.org/Qoj5 (XML)
to my app.xml manifest?
If yes or not?
Do I need to do anything or set my ns value somewhere to make this work? eg: air.com.company.product ?
Thanks In advance,
Leo
Leonardo
4 Nov 11 at 8:47 am
@Leonardo this is correct you should register with air prefix and for development with debug suffix.
Also you have to properly configure Android permissions which should contain your app id.
p.
Piotr Walczyszyn
4 Nov 11 at 3:22 pm
Just wanted to say ‘thanks very much’ for this. A small demo app like this is perfect to show how this c2dm functionality works.
Great work!
Alex
Alex
6 Nov 11 at 2:48 pm
Thank you, Piotr! Works perfectly!
I would like to add to the wishlist that the extension could use the 36 or 48 px version of the application icon – if possible. Scaling down the 72 px version doesn’t always look good. I had to simplify the 72 px application icon to make the notifications look decent.
Thanks…
Anders
23 Nov 11 at 2:44 pm
Another thing to the wishlist: A function to remove all notifications for the app. I have noticed many of my users click the application icon instead of the notification, which leaves the notification in the status bar. It would be nice to have the possibility to delete all notifications for the app (“all read”).
Anders
24 Nov 11 at 4:11 pm
Hi Piotr, great work!
Just one small issue though, with flex 4.6 if an app is packaged with the captive Air Runtime, the icon that displays for notifications is the adobe air icon and not the application’s own icon.
When not using the captive runtime the app’s own icon is used properly.
I know this isn’t the fault of your code, but do you know of a workaround to use the captive runtime, and still have your own app icon show up on push notifications?
Michael
6 Dec 11 at 4:23 pm
Hi Piotr, i’ve tried your example but when i run the cd2m app on my device and click on Register, after a few seconds, i get a popup saying the app cause and error and a force close button.
Any help? Thanks
Antonio
9 Dec 11 at 12:25 pm
@Antonio I never had an issue like that.
p.
Piotr Walczyszyn
12 Dec 11 at 4:39 pm
[...] Worth reading: Adobe Blogs: iOS5 support for AIR/Using external SDKs to package apps MFMailComposeViewController Class Reference Adobe Docs: Building the ActionScript library of a native extension Native Alert iOS native extension tutorial AIR Native Extension Example: iBattery for iOS as3c2dm – AIR native extension to push notifications with C2DM [...]
iOS native extension for Adobe AIR. In-app mail composer | flashsimulations.com
13 Dec 11 at 5:21 pm
Hi Piotr, i’m using FB 4.6 PreRelease on a Samsung Galaxy S2 and always get the error. Can i send you my sample please? I need help urgently!!!!
Antonio
14 Dec 11 at 1:45 pm
Hi again, i can use the .ane file as it comes. I added as extension and can i use the namespace com.riaspace.etc or must download the code and recompile with my com.myapp..etc??
Antonio
14 Dec 11 at 2:24 pm
@Cedric and others interested in iOS version
I’ve created a native extension for iOS push notifications (using APNs), you can give it a try.
It’s still under development, but fully functional.
Extension and example app can be found on GitHub
https://github.com/pkoscierzynski/NativeAPNService
Another AIR extension made in Poland
Piotr Koscierzynski
16 Dec 11 at 2:48 am
How do I add vibration & sound to the messenger? I couldn’t find the format required anywhere.
I added the vibrate permissions to the app and tried to add in the btnSend_clickHandler function this:
obj["data.vibrate"] = 1000;
obj.vibrate = 1000;
Arik
19 Dec 11 at 2:59 pm
@Arik for vibrations and sound you should use different ANE. You can find more here: http://www.adobe.com/devnet/air/native-extensions-for-air.html
Piotr Walczyszyn
19 Dec 11 at 3:37 pm
Hello,
I have some silly questions, but those are taking a lot of time. If anyone answers my questions, that will save my time. I don’t understand how to register with air prefix and with debug suffix. Can anyone help me how to do that? Again when I am registering my appliction with google c2dm, what would be “Package name of Android app”? I created an application named PushNotification where I am usning as3c2dm ANE file. Thanks in advance for your patience to answer my questions.
Thanks,
Nahid
Nahid Shah
21 Dec 11 at 2:04 am
Hi Piotr, Did you mean the Local Notifications ANE?
I want the network notification to vibrate and play sound. Isn’t it possible?
Thanks.
Arik
26 Dec 11 at 2:17 am
Hi,
I tried your example but I received message:
Message was sent, returned result object:
“id=0:1325154727754640%f720122c00000031
”
and don’t have any message go to my phone.
help me please Piotr.
thanks you.
hoangtuanhai
29 Dec 11 at 11:34 am
Hello,
I have some silly questions, but those are taking a lot of time. If anyone answers my questions, that will save my time. I am registering my appliction with google c2dm, what would be “Package name of my Android app”? I created an application named PushNotification where I am usning as3c2dm ANE file. Thanks in advance for your patience to answer my questions.
Nahid Shah
11 Jan 12 at 3:52 am
Seems like the video on this pageis broken. Is there anyway you could write up or link to a step by step tutorial on how to get this to work in our own projects? Including what android permissions need to bechanged inside the AIR XML.
Thanks a lot.
James Lynn
11 Jan 12 at 10:26 pm
@James your wish has materialized
http://youtu.be/qddHBBQHBGE
Piotr Walczyszyn
12 Jan 12 at 7:12 pm
I am also requesting for a step by setp video tutorial. Sometime its really confusing for the new developers to follow what exactly is happening.
Nahid Shah
13 Jan 12 at 12:15 am
My getting started with as3c2dm video tutorial is here: http://www.riaspace.com/2012/01/as3c2dm-getting-started/
IF YOU HAVE ANY ISSUES PLEASE COMMENT IN THE GETTING STARTED POST!
Piotr Walczyszyn
13 Jan 12 at 11:51 am
Hi piotr,
Does as3c2dm works in pure as3 without Flex ?
Thanks
Ben
24 Jan 12 at 5:12 pm
@Ben
Yes it should work with pure AS3 projects.
p.
Piotr Walczyszyn
24 Jan 12 at 5:30 pm
This is a great extension
I really appreciate that fact that you included all the components of the extension (native code and AS3 code), so it’s a great example to look at when learning how to develop extensions.
Thanks a lot for sharing
Julian
31 Jan 12 at 6:37 am
[...] es gibt eine as3c2dm native extension — hier. [...]
Notification Push Service - Flashforum
6 Feb 12 at 5:46 pm
Hi,
Can’t manage to install the C2DMMessenger.air working.
https://github.com/downloads/pwalczyszyn/as3c2dm/C2DMMessenger.air
Has anyone met this problem recently?
Thanks in advance.
Best regards,
Guillaume
Guillaume GARCIA
15 Feb 12 at 11:47 pm
Hi, I also can´t install C2DMMessenger.air.
Does anyone have a solution for this?
thanks
Jorge A.
16 Feb 12 at 12:33 pm
Hi Piotr, many thanks for this great example.
Though I’m wondering, why are you specifying “” in the manifest.xml file, while C2DM and Adobe Air are supported from SDK version 8 and onward? Any particular reason?
Michiel
21 Feb 12 at 11:27 am
Commenting system ate part of my comment. Between “” should be: “uses-sdk android:minSdkVersion=”8″”
Michiel
21 Feb 12 at 11:28 am
And by 8 I mean 10. The example manifest tells us 10.
Michiel
21 Feb 12 at 11:30 am
Hi Piotr, i’ve tried your sample and runs perfect. When i try the same on my app i receive this error on FB when compiling and it’s only happens when incorporate your library and modifications on the manifest file. If i delete all de mods, the apps compile and runs ok:
An internal error occurred during: “Launching Android Version”.
java.lang.NullPointerException
Any hints? Thanks
anibol
22 Feb 12 at 9:55 am
Hello Guys! I have a problem with .ane extension import in this example (I’m using FB 4.6 and I made all necesarry changes required see: http://www.youtube.com/watch?v=qddHBBQHBGE&feature=player_embedded#!) but no result.
All I have is this error: VerifyError: Error #1014: Class com.riaspace.c2dm::C2DM could not be found.
I just don’t get it: I started new Android Mobile Project. I imported the .ane extension and in scripting added some imports like:
import com.riaspace.c2dm.C2DM;
import com.riaspace.c2dm.events.C2DMErrorEvent;
import com.riaspace.c2dm.events.C2DMRegistrationEvent;
Work’s fine.
But when I tried to declare: private var c2m:CMD
I get same error.
Can anyone help me with this?
Best regards!
Ciprian
22 Feb 12 at 11:38 am
Hi Piotr.
Good work. The sample works very well.
Thanks for share with the world.
Agustín Muñoz
16 Mar 12 at 1:01 pm
don’t get it: I started new Android Mobile Project. I imported the .ane extension and in scripting added some imports like:
import com.riaspace.c2dm.C2DM;
import com.riaspace.c
amorsitör
23 Mar 12 at 4:24 pm
Am i the only one who can’t fund the client side app? i can’r open the AIR messenger either- it says the installation is corrupted.
please help.
yonny
28 Mar 12 at 4:11 pm
Thank you for this!
Sadly the C2DM Messenger isn’t working. Says the file is corrupted :/
Daniel
30 Apr 12 at 5:03 am
Any ideas how to give this notification the default behavior?(ring and vibrate)
Daniel
30 Apr 12 at 10:50 pm
[...] you went through Piotr Walczyszy’s tutorial about an Air Native Extension (ANE) to work with C2DM Android service to push messages to Adobe Air [...]
AS3C2DM sound and vibration fix | Flex Brasília - Blog
1 May 12 at 8:51 am
OK, I fixed the sound and vibration problem. Now it works according to the phone’s default configuration. More about it in my blog.
http://www.flexbrasilia.com.br/blog/2012/05/as3c2dm-sound-and-vibration-fix/
Daniel
1 May 12 at 9:00 am
Hello Piotr,
I have the same problem as Ciprian wrote in February:
“I have a problem with .ane extension import in this example (I’m using FB 4.6 and I made all necesarry changes required see: http://www.youtube.com/watch?v=qddHBBQHBGE&feature=player_embedded#!) but no result.
All I have is this error: VerifyError: Error #1014: Class com.riaspace.c2dm::C2DM could not be found.
I just don’t get it: I started new Android Mobile Project. I imported the .ane extension and in scripting added some imports like:
import com.riaspace.c2dm.C2DM;
import com.riaspace.c2dm.events.C2DMErrorEvent;
import com.riaspace.c2dm.events.C2DMRegistrationEvent;
Work’s fine.
But when I tried to declare: private var c2m:CMD
I get same error.”
Please help me with this! I event tried the new .ane file from here: http://www.flexbrasilia.com.br/blog/2012/05/as3c2dm-sound-and-vibration-fix/ – same result.
Thank you!
Eileen
8 May 12 at 11:11 am
Eileen, even I (owner of FlexBrasilia.com.br) am having this same issue. I just woke up today, tried to debug the app that was working fine before and now it’s not working anymore. My bet is on an FB update. Because I’m also having an Alert from FB about error/warning on the ane when I try to debug it. And I never got this Alert before. I’ll come back here if I find the problem.
Daniel
16 May 12 at 9:22 pm
Yep, FlashBuilder update problem regarding the VerifyError: Error #1014.
Here’s how you fix it: http://www.flexbrasilia.com.br/blog/2012/05/flash-builder-verifyerror-error-1014/
Daniel
16 May 12 at 10:54 pm
Thanks a lot to Daniel for his help!! This worked for me. And also thank you to Piotr for this great native extension
Eileen
21 May 12 at 6:41 pm
Thanks a lot for this, it really helped me out!
I just have a question about the app ID you entered when registering with Google for the server side C2DM.
Did you include air in front of your app id (like in the app.xml file)? I can register ok with air in front, but I don’t get any notifications.
Alex
24 May 12 at 12:45 pm
C2DM has been officially deprecated as of June 26, 2012 and has change to Google Cloud Messaging for Android. I am wonder if the extension will work anyway, and does it make any diffrence in develop .
Mech
28 Jun 12 at 11:22 am
@Mech It’s still working in my app, but I read earlier today that the C2DM service will be continued “for at least a year.”
…so everyone keep that in mind. Hopefully by then I won’t need to worry about it. =/
Chaos7703
3 Jul 12 at 3:02 am
I know this project is probably far from your mind Piotr, but according to what I just read at http://developer.android.com/guide/google/gcm/c2dm.html#client, it looks like migrating your ANE to GCM might only require few really simple changes in the ANE & testing app. I could be wrong, but I know that a lot of people would be very happy if they could continue developing their app instead of having to abandon it.
=)
Todd
Chaos7703
5 Jul 12 at 6:50 am
Great job, Piotr!
Are there any plans to migrate this extension to support the new GCM framework?
Thanks.
Alfredo
15 Jul 12 at 2:59 am
I second the recent questions.. is there any chance this could be ported to work with GCM? Or at least some pointers as to how it can be achieved, now that C2DM is no more. Thanks a lot!
Andy
15 Jul 12 at 6:09 pm
Can this be used with Flash cs6 professional using as3?
Ed
28 Aug 12 at 10:12 pm
[...] 推送通知使远程通知提供方将通知发送至在移动设备中运行的应用程序。针对使用 Apple 推送通知服务 (APNs) 的 iOS 设备,AIR 3.4 支持推送通知。 注: 要针对 AIR for Android 应用程序启用推送通知,请使用本机扩展,例如由 Adobe evangelist Piotr Walczyszyn 开发的 as3c2dm。 [...]
air 3.4 移动开发使用后台推送通知 | badyoo RIA技术博客 AS3 flash adobe AIR
12 Sep 12 at 12:33 pm
[...] 推送通知使远程通知提供方将通知发送至在移动设备中运行的应用程序。针对使用 Apple 推送通知服务 (APNs) 的 iOS 设备,AIR 3.4 支持推送通知。 注: 要针对 AIR for Android 应用程序启用推送通知,请使用本机扩展,例如由 Adobe evangelist Piotr Walczyszyn 开发的 as3c2dm。 [...]
air 3.4 移动开发使用后台推送通知 | Apps开发网
16 Sep 12 at 3:24 am
Here is a FREE Adobe Air extension for GCM messaging. It is fully working (implemented in Google Play marketed app) and there is an example provided in the package.
Unlike some paid solutions it also fetches the payload not only on “resume” but also when the app starts (after being closed by user or Android OS) You can download it here: http://wp.me/p2Inzv-9
AfteriskTech
22 Sep 12 at 9:09 pm
[...] Более подробно о работе расширения с использованием автоматических уведомлений можно ознакомиться здесь. [...]
Использование Google Cloud Messaging в Adobe AIR приложениях
13 Dec 12 at 11:14 am
[...] More detailed information on the extension using automatic notifications can be found here. [...]
Using of Google Cloud Messaging in Adobe AIR Applications
17 Dec 12 at 5:16 am
Michael, you wrote:
Just one small issue though, with flex 4.6 if an app is packaged with the captive Air Runtime, the icon that displays for notifications is the adobe air icon and not the application’s own icon.
Problem solved here:
http://blog.denivip.ru/index.php/2012/12/how-to-use-google-cloud-messaging-in-adobe-air-applications/?lang=en
Diestro
9 Jan 13 at 7:59 am
There are many galleries and museums you can check out
in United Kingdom that will delight you and you could
possibly get in for free. A quick survey of a few friends led
to these answers:. You can further enjoy videos with fingering, massaging,
crack heading, fucking, boobs squeezing, sucking, licking and
others.
zumba-fuzion.com
19 May 13 at 4:20 pm