Local Notification ANE – Source Code

I started using Adobe Native Extensions ANE on iOS projects months ago, but then I quickly felt limited because sometimes extensions didn’t do exactly what I wanted and sometimes there was no native extension for some not widely used iOS features. Then I started studying Objective-C to try to overcome these limitations myself. I started by modifying the Daniel Kostler’s Local Notification ANE posted in the Adobe site (see Added Features below).

This post explains how to download the ANE source code and update it if you want to. If you only want to include the ANE in your Flash projects see my next post here.

I know little about Android but yet managed to add some features though not all of them.

Added Features

  • Placed all classes in a new namespace.
  • The NotificationManager.applicationBadgeNumber property allows you to set and get the value of the application icon badge number.
  • The Notification class has three additional properties:
    • fireDate: This property will let you pass a Date object with the date when you want the notification to be triggered.
    • repeatInterval: This property allows you to define a repeat interval between notifications. If no repeat interval is specified it triggers a single time. This property must be set to one of the constants in the NotificationTimeInterval class.
    • soundName: This property specifies a sound file name to play. For the sound to play it must be a wav, aiff or caf sound file using Linear PCM, MA4, µLaw or aLaw format and must be shorter than 30 seconds. It seems AIR is converting from MP3 to the needed formats.
  • The native iOS code was cleaned up. It looks like at the beginning they were trying to support Local as well as Remote(Push) Notifications. But then they just decided to support only Local, and a lot of garbage code was left in there. Besides, this test code was depending on a large library that was not included with the ANE. Without this library the project couldn’t compile.
  • Added a default version of the ANE that does nothing, to allow compiling debug versions on Desktop computers.
  • Documentation updated to reflect the extension additions.

The ANE Source Code

First you need to download the LocalNotification project source code from Github here. You can clone the project using Git:

git clone https://github.com/juank-pa/JKLocalNotifications-ANE.git

ActionScript Code

If you are going to add features to the component requiring a new interface in the ActionScript side you need to edit the Flash Builder project:

  1. Open Flash Builder. You need Flash Builder 4.6.
  2. Select File > Import Flash Builder Project
  3. Select the Project folder option and then click on Browse
  4. Navigate to the folder where you cloned or unzipped the source code:
  5. Once you accept the project appears in FlashBuilder
  6. Do the changes you want
  7. Open the project properties by selecting Project > Properties
  8. Go to the Flex Library Compiler Tab. In Additional Compiler Arguments you’ll see some -define options:
    • CONFIG::device: This option must to true to build the Device version and false to build the Desktop version. When this flag is false all other flags are ignored.
    • CONFIG::iphone: This option must be true to build the iOS version. For this to work CONFIG::device must be true and every other device flag must be false.
    • CONFIG::android: This option must be true to build the Android version. For this to work CONFIG::device must be true and every other device flag must be false.
  9. Compile each version by toggling the above compiler arguments and then selecting Project > Build Project.
  10. Every time you build, rename the resulting SWC file to prevent it being replaced by the next build.
  11. For information on how to create the ANE ActionScript side see:
    Coding the ActionScript side

Objective-C Code

Once you added the interface you need to actually add those features in native code:

  1. Install the latest version of XCode
  2. Open the folder where you cloned or unzipped the source code and open the XCode project located at:
  3. Make the changes you want to the project located at the LocalNotificationLib folder in the project navigator.
  4. Choose the target to compile from the list next to the Stop button on the top bar. The project has two targets:
    • The target called LocalNotificationLib compiles the static library used for the ANE.
    • The target called LocalNotificationTest is a native iOS application that allows you to test the notifications directly in the emulator or device.
  5. Ensure the target device is set to iOS Device and not any Simulator. This is very important.
    XCode Target
  6. Select Product > Edit Scheme in the menu.
  7. Ensure the build configuration is set to Release. This is not mandatory but release builds will run faster.
  8. Build the project.
  9. Once built a Release folder will appear in the XCode LocalNotifications project folder. Here you’ll find a LocalNotificationLib.a file which is the native library for the ANE.

For more information on coding AIR extensions see: Developing Native Extensions

Packaging the ANE

Now you have all the necessary assets to create the package:

  1. Copy all the three .SWC versions created in Flash Builder to this folder:
  2. For each copy:
    1. Change the extension from .SWC to .ZIP
    2. Open or decompress and open the ZIP file
    3. Copy the library.swf file to the corresponding folders i.e. the Android SWF file to the [download-path]/bin/android folder, the iOS SWF file to the [download-path]/bin/iphone folder, and the default SWF file to the [download-path]/bin/default folder.
  3. Change the name of the .SWC file of the default version to LocalNotificationLib.swc. You can delete every other .ZIP/.SWC file if you want.
  4. Copy the LocalNotificationLib.a file from [download-path]/src/XCode/LocalNotificationLib/Release to [download-path]/bin/iphone folder.
  5. Open a Terminal and type:

"/Applications/Adobe Flash Builder 4.6/sdks/4.6.0/bin/adt" -package -target ane LocalNotificationLib.ane extension.xml -swc LocalNotificationLib.swc -platform Android-ARM -C android . -platform iPhone-ARM -C iphone . -platformoptions options.xml -platform default -C default library.swf

That’s it, the new ANE file should be there for you to use it in you own projects. By the way I’m using the default Flash Builder install folder here but change the path if you have it installed somewhere else. Also, I divided the terminal command into multiple lines for convenience but everything must be placed in a single line. I’m not very good at Linux or Terminal commands. If somebody can help with a good script to automate the process I’ll be glad.

I hope this post will help you, not only to add additional features to this ANE but also as a Getting Started point on creating your own ANEs.

If you’re interested in donating, do it here.

Thanks in advance!

65 thoughts on “Local Notification ANE – Source Code

  1. Hellow! I am build test project “Sample.apk”, and it is open on my device (Xiaomi redmi note 4), but local notifications not work, nofing happanes when i am push on post button, not any error but not working. Please help! (Sorry for my poor english)


  2. Hi,
    I need help. I am using this ANE for local notification. I want to show the icon also on notification. There is one setting for notification is iconType but it has info/message/error/document/flag. This setting is showing only such type but i want to show the our App icon. Please help me how i can show the icon.


  3. Hi Juan,
    tks for the extension – the ANE rocks! 🙂

    I have a question about the repeatInterval: is it possible to set the repeat time to 30 secs? I saw the constants but there is only 1 second or 1 minute and no in between value.

    Tks in advance for your time -_^



  4. Hi,
    great ANE! works great on real device.

    I got a problem: how do you check whether there is existing notification before setting new ones? If check is not in place, the app could be setting duplicate notifications I’m afraid.



  5. i can’t have it run on galaxy tab 10.1 , i got the latest update for AIR , i used the same sample code u provided for flash cs6 i used both sdks 3.3 and 3.5


  6. you know you are my hero. seriously for making this. my app is useless without this.
    unfortunately, i think there is a small bug still 😦

    cancel() for a specific notification does not remove the notification from the notification center. cancelAll() works but i am spending days and days trying to figure out a work around for this. (i’m using multiple notifications and i’m going insane. every time there is a change, i cancelAll() and rebuild them all again).
    any chance this is an easy fix for you. as always, thanks so much.


  7. Juankpro,

    Excellent work.

    I just want to point out one small thing that got me stuck for a bit, not being too savvy with the compiler settings.

    If you are working on Flash Builder 4.7, this is how you add the compiler parameters:

    -locale en_US -define=CONFIG::device,true -define=CONFIG::iphone,true -define=CONFIG::android,false

    I know this page http://juankpro.com/wordpress/2012/05/10/local-notification-ane-source-code/ has something about this, but it was not specific on how to type them in.

    Otherwise the program won’t compile, complaining about the ‘device’ setting. Just in case anybody is having the same issue.


    1. Are you trying to use the ANE as is. Because if this is the case you don’t even have to worry about compiling the ANE itself which needs this definitions but only use it. For just using it there is no need to set any CONFIG::x option. You only need this if you want to update functionality on the ANE.


  8. I added .ane file in Source path instead of adding in “Native Extensions” tab in Flash Builder and now it is compiling the ANE with the given compiler arguments.

    But now creation of _extensionContext is failing in NotificationManager.as:(line#49) and ExtensionContext.createExtensionContext() is returning nothing but a null.
    _extensionContext = ExtensionContext.createExtensionContext(“com.juankpro.ane.LocalNotification”, _contextType); //_contentType = “LocalNotificationsContext”

    What am I doing wrong?


    1. The extension.xml file in your ANE has platforms Android-ARM, iPhone-ARM and default. It does not include iPhone-x86. Does that mean the ANE can’t be used on Flash Builder’s iPhone/iPad Simulator?


      1. It would not compile for Simulator right now. I’ve never test it on simulator but I read in a blog that you can have iPhone-x86 or iPhone-ARM in the ANE but not both. This is why I haven’t changed it. Anyway you’re free to either add iPhone-x86 o replace it, recompile the ANE, and make your own tests to see if it works.


  9. I am using this ANE with FB4.6+AIR3.4
    Added .ane file in NativeExtensions tab and set compiler arguments
    -define=CONFIG::device,true -define=CONFIG::iphone,true
    However, CONFIG:device seem to be returning “false” and the static function isSupported() is always returning false. What am I missing?


  10. Hello,
    I was wondering if you could help me a error I’m getting.

    the sample compiles fine but when I run the program I get this error:
    “VerifyError: Error #1014: Class com.juankpro.ane.localnotif::NotificationManager could not be found.” I’m using flash builder 4.6 and AIR 3.4 I follow the instruction and I’m stuck at the moment..

    Flash Builder 4.6 — > AIR 3.4


  11. Hi,
    first of all: Nice ANE! I’m so happy it exists 🙂
    But I’ve problems compiling my app.
    The error is:
    ld: unknown option: -ios_version_min
    Compilation failed while executing : ld64

    I know the older posts, with this problem. You wrote thats a problem on PC, but I’m using a Mac with newest OSX.

    I use the original 4.6.0 SDK – cause another ANE currently isn’t running on newer SDK Versions.
    Any idea how to fix the problem?



    1. In theory you can re-compile the ANE using the .sh files included in the bin folder. But first you’ll need to remove the -options option from this .sh file. That might help but not sure. The ANE might be using iOS features that might not be supported by the AIR SDK you use


  12. Good news to everyone. I have re-written the Android part almost completely to support triggering the notification at a later date and at regular intervals on Android devices. I couldn’t make it work with custom sounds though.


  13. Hi. I’ve been working with your ANE and loving it for over a month now. My app is getting close to a release.

    1. I was wondering if it is possible to create a custom sound that can repeat either infinitely or a specific number of times? I have a timer app and would love to give the user the option for the notification audio to repeat. (Perhaps this is not allowed by iOS.)

    2. I noticed that if multiple notifications fire in the background using firedates, the notifications stack up in the notification center. There seems to be no current method to schedule a “cancel” command or “cancelAll” command in a firedate which could help to remove previous notifications in the notification center. That would be a great option for a firedate to “cancel” previous incarnations of the same notification (and “cancelAll”) before it fires. Let me know if I’ve overlooked easy work arounds for this.

    Thanks, again. You are awesome. I know you’ve talked about adding android firedates. Looking forward to that too! Are there enough requests in this post!?


  14. Original code by Daniel was supporting only one notification for a single code. Now it supports many of them and you can cancel all with the same code.


  15. Strangely, mp3’s for custom sound notifications are working fine when I do an app store build from CS6. This isn’t on the list of possible working formats from apple but somehow AIR is letting it work I guess. Celebrate!


  16. a man’s work is never done! right! well, here we go again. i am having a problem with canceling notifications. this is tiny compared to the awesomeness of this ANE. but…
    my app uses multiple alarms that the user can cancel.
    cancelAll() seems to reliably cancel everything (firedates and every notification listed in the notification center).
    cancel() seems to work well to cancel a specific firedated notification. but it is spotty in removing a notification already listed in the notification center. especially if you’ve called the notification twice or more and it is appearing multiple times in the notification center. to keep it from appearing multiple times, i’d like to cancel() it, before i notifyUser() again. but it’s not really working.
    I can get around this with cancelAll() but its a lot messier for me.
    thanks for listening to my whining!


  17. You are a madman! That’s great. The new sound option works great. I wish it had the ability to use mp3’s but I’m sure that’s an iOS limitation. Also, it builds now in CS6 without the command line. That’s awesome! Thanks!


  18. I added support for custom sounds. Review the sample in particular: FlaSample.as (uses the soundName property), Terminal.txt (command line now adds a sound), and the updated “Added features” section in this blog.


  19. Any chance this can easily be updated to use custom sounds with firedates? I know that option is available to xcode users, but I don’t think its implemented in the ANE. Thanks for your hard work!


  20. Wow. You are correct. I don’t know how I missed it. The command line is so fast that I didn’t think it worked. But you are right, the ipa is created without needing the iPhone SDK (–platformsdk). It does generate one new set of warnings (CPU_SUBTYPE_ARM_ALL subtype is deprecated) but the app still functions great. Thanks!


  21. I have confirmed this. Your sample project compiles a working ipa from my PC using AIR 3.3. Using Flash Pro CS6 with AIR 3.3 the ipa would not compile. I let it run 30 minutes with no luck. I had to use the command line you provided in the sample project. The essential new component of the command line is: “-platformsdk” that points to the iPhone SDK folder. This folder can be copied (carefully) from a mac.
    There is a working link on this page where a nice person has uploaded a working zip of the SDK for PC users. Worked for me!


    1. Yes, it seems some of the warnings generated while compiling makes Flash CS6 to hang up forever. But this doesn’t happen when compiling with the command line. I didn’t even had to use the platformsdk parameter to compile it on PC.


    2. Hi – Can you type an example of the exact command line code required to build the ipa file as when I followed the example on the abode website, it returns as storetype required. Thanks.


  22. Hello. I’m using your Local Notification ANE as binary file included in your bitbucket repository. Many thanks to your great work! I’m using FlashDevelop on PC. I met the same error “ld: unknown option: -ios_version_min” on packaging to .ipa file on PC and failed to package. Recently AIR 3.3 has released and I use adt command which is included in AIR 3.3 SDK, and packaging is done and the created app (and ANE) works well though with many warning: “ld: warning: ARM function not 4-byte aligned” ! So you might create IPA even on PC by using AIR 3.3 SDK. Thanks.


    1. Hey that’s good news! The “ARM function not 4-byte aligned” warning is normal. Adobe is aware of this warning but it is harmless.


  23. At last I have got this partially working using Flash Pro CS6. I assume this will work fine in CS5.5 using the command line.
    You must create the IPA on a Mac. I get the same error message (“ld: unknown option: -ios_version_min”) on both PC and Mac unless I add a path to the iOS SDK (see step 4 below) which will only be possible on a MAC I believe.

    In the “Advanced AS3 Settings” Panel :
    1. Set an ANE library path to the “LocalNotificationLib.ane” file (a new feature in Flash Pro CS6)
    2. Set a SWC path to the “LocalNotificationLib.swc” (set link type to “external”)
    3. Remove any code using “isSupported” from your flash project code. (I get errors if I try to use this.)
    4. In the “Air for iOS Settings Panel” (on the “general” tab) you will see a new feature in CS6 on Macs. Namely a path to the iOS SDK. The path I used was:
    which I got from this source:

    I’m not sure that every step is necessary. But these have worked for me.

    I’ve been praying for this to work for an eternity!
    Thanks for making this available Jaun.


    1. Yes that is the exact process. All this steps were going to be available on the next post but I haven’t got any time to write. Thanks for your comments Brad!


  24. Hi – I understand about the .IPA file but I encountered an error while including the ANE file into my project specifically for iPhone. When I compiled a release build or a debug build, it reports an error as follows:

    ld: unknown option: -ios_version_min
    Compilation failed while executing : ld64

    I am importing the package as follows

    and also it reports “notificationManager.isSupported” is not found?!!
    All the above lead me to believe, there was something missing in the ANE file and not a fully compiled one and why I asked you?

    If you think you can share a sample project with the working ANE included, would be appreciated.



    1. All this problems arise because it was not possible to compile from PC. The new AIR 3.3 now supports compiling this ANE on PC. Try downloading it. Also the isSupported method is a static method so it must not be called from an instance but from the class NottificationManager.isSupported. I updated the Git repository to include a FLA sample.


    1. Sorry, I think we misunderstood. What I meant was that the binary LocalNotificationLib.ane is already there in the bin folder. But because of some restrictions it is not compiling when used in PC Flash/Flex projects. Hence the only thing I can help you with is take your final project or sample and compile it on a Mac to create a .IPA file (the final iOS app). But now that I think about it, even that can be problematic because I need your iOS certificate (the .p12 file) and that information is commonly sensitive.


  25. Hi Juankpro – Wondering if there is a compiled ane to work with for iOS devices. Currently, if my understanding is correct, this is the source code and I need a mac to compile it using iOS SDK 5.
    I dont have a mac and was wondering if you can compile the code and release a build for me to include to test on iOS devices.



    1. Hey Anon – Sadly I ended up with the conclusion that this ANE will only compile only on Mac. It might be because of some settings of the new iOS SDK. I always need to reference the iOS SDKs folder from the AIR packager. Making it impossible to compile in PC ven when this ANE doesn’t references any non-shared library. But I think I could compile a test for you NP.


  26. Hi it is not working on My mac.. Xcode projective is giving error..Enable to find “ExtensionUtils.h” in file LocalNotificationsContext.m…Please help


    1. Hi vinay:
      The project had some dependencies that I forgot to include in the repository.
      I fixed this already so you can download it again. Tell me if everything is working now.


  27. this is great work you are doing!
    i did a post showing how to use the original adobe ANE with Flash Pro: http://bradwallace51.wordpress.com/2012/02/02/using-adobes-notification-air-native-extension-with-flash-professional/
    this issue has perplexed me to no end. i never realized that you even needed to schedule notifications. i thought that timers inside the app would work in the background and fire off the notifications for you. i have definitely gotten that concept to work in Android without a hitch. i actually did also figure out a way to get my app to run and schedule notifications in the background on iOS but Apple rejected my app (since this consumes too much energy in the background i assume). but after seeing your post and your comments on the adobe notification forum page, i realize that there are more efficient methods of getting this done (namely letting the OS handle scheduled notifications).

    my timer app is dead in the water until i can get this figured out. so i’m very impatient for your post with instructions on the use of this ANE you have created! in the meantime, can you provide some insight?

    can i create and test on a PC? or do i have to use a MAC?
    on my PC in Flash Pro, i have used the same code as was working with Adobe’s version of the ANE, except:
    1. changed the import namespace to: com.juankpro.ane.localnotif.*
    2. changed the as3 settings library path to point to your swc with link type: external.
    3. changed the -app.xml to read: com.juankpro.ane.LocalNotification

    i get build errors unfortunately. for example it says “Class com.juankpro.ane.localnotif::NotificationManager could not be found.”

    thanks for releasing this to everyone!


    1. Hey Brad, I’m not so sure it’s going to work on PC, but just let me try it and I’ll surely include instructions on the next post for both Mac and PC if it works. Also I might add a Flex sample to inside the project.


  28. Nice job!

    Would you add an sample of as3 code for using your push ane?
    I’m specially interested in a fireDate sample..

    Would be awesome! 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s