Using the Local Notification ANE

This component allows sending Local Notifications that will trigger on a later date. It lets you specify message text, buttons, sound to play, a date to trigger, the interval between notifications, and more…

Now I’m going to explain how to use my modified version of Local Notification ANE using Flash CS5.5/CS6 and Flash Builder 4.6. If you want to improve the ANE with your own source code see instructions in my previous post here. You will also find a list of the added features there.

Important!
The Android version doesn’t support custom icons and sounds.

Prerequisites

Set up your path variables

I’m new to Mac so I don’t know a lot of stuff, hence I used absolute paths to reference AIR SDK tools. I didn’t had to do anything for JAVA on Mac. I don’t know if Macs come with JAVA pre-installed, or if the path is already configured for you when you install JAVA. For Windows you must add the following path variables:

  1. Add a system’s path variable to point to AIR SDK command line tools. Open Windows Start Menu, type “path” and choose “edit environment variables for your account” (Windows 7). Choose “Path Variable” and click “Edit”. Type or paste in the path to your downloaded AIR SDK’s bin directory at the end of the current path. Use a semicolon (without any spaces) between any path’s that are already in the variable.
    For example: ;C:\AIR SDK 3.3\bin
  2. Set up your system’s path variable to point to your JAVA command line tools in the same manner as the previous step. The ADT tool needs JAVA.
    For example: ;C:\Program Files\Java\jre7\bin

Overlay AIR SDK in Flash Professional/Flash Builder

Overlay AIR SDK 3.3 or later first. Without doing this, all editors use an old version of the SDK:

Using the ANE on Flash Professional CS5.5/CS6

This is a simple iOS app with three buttons and a textfield. The first button will schedule a notification to trigger after 15 seconds. You can press this button an quit the application to see how the notification triggers. The second button simply cancels the previously scheduled notification and the third button clears the debug textfield and resets the application badge number to zero.

  1. Create a new Flash document called sample.fla
  2. Copy the LocalNotificationLib.ane file from /bin folder, and paste it next to your FLA file.
  3. For Flash CS5.5 only, change the LocalNotificationLib.ane file extension to .swc.
  4. Go to File > Actionscript Settings, and choose the Library Path tab.
  5. Click the plus (+) button to add a new entry.
  6. Import the ANE file:
    • On Flash CS5.5:
      1. Click the “Browse to SWC” button and browse to the LocalNotificationLib.swc file you renamed.
      2. While the imported SWC is selected press the “Set linkage options for a library” button (info icon).
      3. In “Link type” select “External”. Press OK twice.
    • On Flash CS 6.0 click “Browse To Native Extension (ANE) File” and Browse to the LocalNotificationLib.ane file you copied and press OK.
  7. Go to File > Publish Settings:
    • On Flash CS5.5 change the Player to AIR for Android/iOS.
    • On Flash CS6 change the Player to AIR 3.3.0.xxxx or higher for Android/iOS.
  8. On Flash CS6 only, go to File > Air for iOS Settings, then to the Deployment tab:
    1. Browse to your developer certificate .p12 file in the Certificate field.
    2. Type your certificate password and select the “Remember password for this session” option to avoid writing the password every time.
    3. Browse to your provisioning profile file in the Provisioning profile field.
    4. Write a valid App ID.
      You’ll find information on how to get all needed assets from Apple here.
  9. Create three buttons in the Stage and give them instance names “button1”, “button2” and “button3”.
  10. Create a TextField in the Stage and give it an instance name “notificationTF”.
  11. In the Properties Panel, set the document Class to “FlaSample”.
  12. Click the pencil icon to open “FlaSample”, erase all current code, and paste:
    package  {
      import flash.display.MovieClip;
      import flash.display.SimpleButton;
      import com.juankpro.ane.localnotif.NotificationManager;
      import flash.events.MouseEvent;
      import com.juankpro.ane.localnotif.Notification;
      import com.juankpro.ane.localnotif.NotificationEvent;
      import flash.text.TextField;
    
      public class FlaSample extends MovieClip {
        private var notificationManager:NotificationManager;
    
        public var button1:SimpleButton;
        public var button2:SimpleButton;
        public var button3:SimpleButton;
        public var notificationTF:TextField;
    
        private static const NOTIFICATION_CODE:String = "NOTIFICATION_CODE_001";
    
        public function FlaSample() {
          if(NotificationManager.isSupported) {
            notificationManager = new NotificationManager();
    
            notificationManager.addEventListener( NotificationEvent.NOTIFICATION_ACTION, notificationActionHandler);
            button1.addEventListener(MouseEvent.CLICK, buttonClickHandler);
            button2.addEventListener(MouseEvent.CLICK, buttonClickHandler);
            button3.addEventListener(MouseEvent.CLICK, buttonClickHandler);
          }
        }
    
        private function buttonClickHandler(event:MouseEvent):void {
          switch(event.target) {
          case button1:
            var notification:Notification = new Notification();
            notification.actionLabel = "OK";
            notification.body = "Body sample";
            notification.title = "Title";
            notification.fireDate = new Date((new Date()).time + (15 * 1000));
            notification.numberAnnotation = 1;
            notification.actionData = {sampleData:"Hello World!"}
    
            notificationManager.notifyUser(NOTIFICATION_CODE, notification);
            break;
          case button2:
            notificationManager.cancel(NOTIFICATION_CODE);
            break;
          case button3:
            notificationManager.applicationBadgeNumber = 0;
            notificationTF.text = "";
            break;
          }
        }
    
        private function notificationActionHandler(event:NotificationEvent):void {
          notificationTF.text = "Notification Code: " + event.notificationCode + "\nSample Data: {" + event.actionData.sampleData + "}\n\n";
        }
      }
    }
    
  13. Press Ctrl+Enter to preview the app in Flash. You might get an error on CS5.5 do to the External library settings but this is normal.
  14. Only on Flash CS 6.0 open File > Air for iOS Settings, press the Publish button, and you’re done!. This will create an IPA file next to the FLA file. For information on how to upload the IPA file to the device see here.
    If you are using Flash CS5.5 instead, follow to the next step.
  15. Next to your FLA file, create a new text document called “sample-app.xml”.
  16. Paste the following XML code inside it and save it:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<application xmlns="http://ns.adobe.com/air/application/3.3">
    <id>com.juank.Sample</id>
    <versionNumber>1.0</versionNumber>
    <filename>sample</filename>
    <description></description>
    <name>sample</name>
    <copyright></copyright>
    <initialWindow>
        <content>sample.swf</content>
        <systemChrome>standard</systemChrome>
        <transparent>false</transparent>
        <visible>true</visible>
        <fullScreen>false</fullScreen>
        <autoOrients>false</autoOrients>
        <aspectRatio>portrait</aspectRatio>
        <renderMode>auto</renderMode>
    </initialWindow>
    <customUpdateUI>false</customUpdateUI>
    <allowBrowserInvocation>false</allowBrowserInvocation>
    <icon></icon>
    <iPhone>
        <requestedDisplayResolution>standard</requestedDisplayResolution>
        <InfoAdditions><![CDATA[<key>UIDeviceFamily</key><array><string>1</string></array>]]></InfoAdditions>
    </iPhone>
    <android>
        <colorDepth>16bit</colorDepth>
        <manifestAdditions><![CDATA[
            <manifest android:installLocation="auto">
                <uses-permission android:name="android.permission.VIBRATE"/>
                <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
                <application>
                    <service android:name="com.juankpro.ane.localnotif.LocalNotificationIntentService"/>
                    <receiver android:name="com.juankpro.ane.localnotif.AlarmIntentService" />
                    <receiver android:name="com.juankpro.ane.localnotif.AlarmRestoreOnBoot" >
                        <intent-filter>
                            <action android:name="android.intent.action.BOOT_COMPLETED" />
                        </intent-filter>
                    </receiver>
                </application>
            </manifest>
        ]]></manifestAdditions>
    </android>
    <extensions>
        <extensionID>com.juankpro.ane.LocalNotification</extensionID>
    </extensions>
</application>

UPDATE:

I added a new permission and registered a new service in the application XML to allow recovering notifications on boot on Android.

  • Replace the id tag content with you own Bundle Identifier. You’ll find information on how to get the app ID from Apple here.
  • Open a command window “cmd.exe” on Windows or the Terminal on Mac and type:
    • Windows:
      adt -package -target ipa-ad-hoc -storetype pkcs12 -keystore  -provisioning-profile  sample.ipa sample-app.xml sample.swf -extdir
      
    • Mac:
      /Path_to_AIR_SDK_bin/adt" -package -target ipa-ad-hoc -storetype pkcs12 -keystore  -provisioning-profile  sample.ipa sample-app.xml sample.swf -extdir
      
    • Replace with your own certificate .p12 file path and with your own .provisioning profile file paths. You’ll find information on how to get all needed asets from Apple here

If everything worked well, hopefully, a sample.ipa/sample.apk file will appear next to your FLA file. For information on how to upload the IPA file to the device see (http://help.adobe.com/en_US/as3/iphone/WS144092a96ffef7cc-4ae52ec4126ab9d6ce6-8000.html)%5Bhere%5D.

Using the ANE on Flash Builder 4.6

This is a simple iOS app with three buttons and a TextArea. The first button will schedule a notification to trigger after 15 seconds. You can press this button an quit the application to see how the notification triggers. The second button simply cancels the previously scheduled notification and the third button clears the debug textfield and resets the application badge number to zero.

  1. Create a new Flex Mobile Project with File > New > Flex Mobile Project
  2. Set LocalNotificationTest as project name and choose a location for your project. Press Next.
  3. For simplicity deselect Blackberry Tablet OS. Press Finish.
  4. Copy the LocalNotificationLib.ane file from /bin folder, and paste it in your projects root folder.
  5. Select Project > Properties
    1. At Flex Build Path section > Native Extension press the “Add ANE” button to select the copied LocalNotificationLib.ane file
    2. At Flex Build Packaging > Apple iOS:
      1. In the Digital Signature tab browse to select your certificate and provisioning profile. You’ll find information on how to get all needed assets from Apple here.
      2. In the Native Extensions tab select the checkbox next to the LocalNotificationLib.ane file in the table. If a warning appears press Yes.
  6. Open the LocalNotificationTest-app.xml file and replace the id tag contents with your own Bundle Identifier. You’ll find information on how to get all needed assets from Apple here.
  7. Open the “LocalNotificationTestHomeView.mxml” file, erase all current code and paste:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" creationComplete="view1_creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import com.juankpro.ane.localnotif.Notification;
            import com.juankpro.ane.localnotif.NotificationEvent;
            import com.juankpro.ane.localnotif.NotificationManager;

            import mx.events.FlexEvent;

            private static const NOTIFICATION_CODE:String = "NOTIFICATION_CODE_001";

            private var notificationManager:NotificationManager;

            protected function view1_creationCompleteHandler(event:FlexEvent):void
            {
                if(NotificationManager.isSupported)
                {
                    notificationManager = new NotificationManager();

                    notificationManager.addEventListener( NotificationEvent.NOTIFICATION_ACTION, notificationActionHandler);
                }
            }

            protected function button_clickHandler(event:MouseEvent):void
            {
                if(!notificationManager) return;

                switch(event.target)
                {
                    case button1:
                        var notification:Notification = new Notification();
                        notification.actionLabel = "OK";
                        notification.body = "Body sample";
                        notification.title = "Title";
                        notification.fireDate = new Date((new Date()).time + (15 * 1000));
                        notification.numberAnnotation = 1;
                        notification.actionData = {sampleData:"Hello World!"}

                        notificationManager.notifyUser(NOTIFICATION_CODE, notification);
                        break;
                    case button2:
                        notificationManager.cancel(NOTIFICATION_CODE);
                        break;
                    case button3:
                        notificationManager.applicationBadgeNumber = 0;
                        notificationTF.text = "";
                        break;
                }
            }

            private function notificationActionHandler(event:NotificationEvent):void
            {
                notificationTF.text = "Notification Code: " + event.notificationCode +
                    "nSample Data: {" + event.actionData.sampleData + "}nn";
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Button id="button1" x="55" y="10" width="211" label="Send" click="button_clickHandler(event)"/>
    <s:Button id="button2" x="55" y="61" width="211" label="Clear" click="button_clickHandler(event)"/>
    <s:Button id="button3" x="55" y="112" width="211" label="Reset" click="button_clickHandler(event)"/>
    <s:TextArea id="notificationTF" x="10" y="163" height="242"/>
</s:View>
  1. You can Debug your project if you want (Optional). The first time you debug you might have to select “On desktop” as Launch method and select a target device on the dialog that shows.
  2. To compile the iOS App select Project > Export Release Build and click Next
  3. In the “Digital Signature” tab, fill the Password field with your certificate password.
  4. Select “Final release” or “Ad hoc” as package type depending on your certificate type.
  5. This will create an IPA in your projects root folder. For information on how to upload the IPA/APK file to the device see here.

How to use sample files

To use the sample files you’ll need to replace the App ID, certificate .p12 file and provisioning profile file paths with your own data and then build the IPA file using the method corresponding to the editor you use (Flash CS5.5, Flash CS6 or Flash Builder).

To compile on Flash CS5.5, I provide shell script files to compile the sample on Mac. You need to change the paths to certificates and provisioning profiles in theses files too.

Final words

Hope this tutorial and the ANE itself is useful. I’m planning to do more components.
If you’re interested in donating, do it here.

PayPal

Thanks in advance!

129 thoughts on “Using the Local Notification ANE

  1. Hello
    I would like to use this component with android it work but I dont have the sound I have ony the buzzer

    It’s normal ? if yes do you have a solution for have a sound ?

    thank you for your help

    Like

    1. Yes, I don’t know much about Java for Android so this didn’t help me while trying to use custom sounds. I prompted people to see it they had any ideas. Some of them helped me a bit but I haven’t got any time to play with it.

      Like

  2. This is the easiest to understand notification tutorial I have read so far. It works well on iOS.

    1. On android is seems to trigger the alert immediately after pressing button1. Changing the notification.fireDate doesn’t seem to make any difference. Is the custom XML data a requirement to get it working correctly? Right now I’m just publishing it to my device from flash cs6 and not compiling it from command line with a custom xml.

    2. Is the correct way to remove a single alert from multiple alerts to be to make the NOTIFICATION_CODE value unique for each alert and target the corresponding string ID?

    Like

  3. tried on android, work nicely but when i end the application the event cant trigger, does it suppose to be work even after u end the application?

    Like

  4. Hi, i tried to use this for an anodrid application, no errors encounteres, all is in the package and it runs on my samsung, but when I press the button send nothing happens afetr 15 seconds. Any help or advice?

    Like

  5. In Android it works as long as the app is open or in the background.
    i added the XML stuff also giving permissions in boot and all.
    once i close the app from the memory, there are no notifications.
    Its supposed to work ? what i can do ?

    Like

  6. Hello and thanks for this great ANE.

    I’m trying to fire a notification whit the sample code on iOS, and everything works fine except the sound. There is not sound when the notification fires, and in the notification center settings, sounds is switched off for this app.

    How can I play a sound when the notification apears? I need to put something in the app description xml file? I need to put something else in the code? Thanks!

    Like

      1. Hi Juan,

        Same issue here: notification sound is no longer working on iOS. It used to work just fine a while back, on my iPad1. Though, no longer as of 5.1.1, and possibly earlier.

        Like

        1. As far as I know it seems rules have been changing in the latest AIR SDKs/Platform regarding access to external assets.
          That might be the reason. I’ll have to check it out. I stopped support to this ANE for a long time now.

          Like

          1. Hi Juan

            Thanx for a great extension.

            Do you have any more insights on why the sound is not working iOS anymore

            I do event get the default notification sound,
            its just quiet :-/

            Thanx in advance

            Like

          2. I made a test and it worked, compiled with AIR 3.9 and on iOS 7.1.
            Maybe you are forgetting to add the file to the IPA. When compiling there is an option to include external files. To check if your sound is in there you can change the extension of your IPA to ZIP. And check if your sound is in the Payload/.app folder.

            Like

  7. Hi juan,

    The notification works nice. However, at least for android, it would be nice to use de app icon. I used this one: https://github.com/patrickkulling/Air-Mobile-Extensions/tree/master/notification . It uses the app icon, but it has no event fired when I tap the notification. In your’s it takes me back to my app (that’s the correct behavior for most notifications from apps in background).
    I think this feature is a must… I really have no idea how to modify the sources of your ane to achieve this.

    Like

    1. I don’t have much time to update anything. The icon stuff must be easy to implement though. Anyway a fast way to achieve this is changing the icons image directly on the eclipse project. Recompile the project and recompile the ANE. All necessary files to do this are in the package. To do this in Mac at least. Don’t remember if this was working on PC.

      Like

  8. Dear Juan,

    i have a small question… if i add multiple notifications at the same time with the same notificationID ex:

    //as code
    var notificationID:String = ‘alarm’;
    notificationManager.notifyUser(notificationID, notification);
    //——–end code————-

    if i use “notificationManager.cancel(notificationID)”, will it cancel all the notifications with the same notificationID “alarm” or it will only cancel the latest notification set with this ID?

    thank you and very useful ANE.

    Like

    1. The ANE is not handling this case. So if you add a second notification with the same id then the last notification replaces the previous in the database and you will not be able to cancel it. Typically notificationID should be a unice ID. You should not use it for more than one notification.

      Like

  9. Hi, a very useful app, congrats!
    But I have a problem using it XD.
    I’m launching a notification, and then in the Listener I launch it again, and so on.
    It works on foreground, but not in background. What it could be?

    Like

    1. The problem is background applications stop running any code. The notifications is just like some data you give to the operating system to make the notification appear at some time in the future. If you are in foreground then the event is passed to your code. But if you are in background then no code is triggered in your app until you click the notification.

      This has changes in iOS 7 so anyone interested in updating the ANE for this would be great. I don’t have time to do this now actually.

      Like

  10. Hello Everybody,
    We used the ANE and it works well on iOS.

    Now we have another specific requirement where we need to add a few coins to the user when he is out of coins after a period of 24 hours.So I need to schedule the notification for that period but as I understand the Notification.NOTIFICATION_ACTION only gets triggered when the user taps on the notification in the notifications tab or unlocks the phone when the notification has come.So It won’t trigger when the user just directly enters the application.
    Is there a way to handle this?

    Like

    1. The notification triggers even if you are in foreground or background. The difference is that if you are in background then a visual notification is shown. But in foreground only the NOTIFICATION_ACTION event is triggered so is up to you to make it work.

      Like

  11. Hi, I am creating new app for setting up Alarm when the time is achieved in Flash Builder4.6 for IOS and Android for personal use.
    I followed the steps mentioned above, but while debugging the ‘notificationManager’ gets the null value. Please guide me step wise for the application for setting Alarm and setting intervals.

    Like

  12. I need specific to re-schedule for a specific time (for example each 5 hours) and currently this is not supported with the constants so I support myself in my fork version.

    If you want to also support this, just add a new variable (for example multiple with default = 1) and use if in LocalNotificationManager.java

    Change the following line:
    am.setRepeating(AlarmManager.RTC_WAKEUP, notificationTime, repeatInterval, pendingIntent);

    To:
    am.setRepeating(AlarmManager.RTC_WAKEUP, notificationTime, repeatInterval * multiple, pendingIntent);

    Now you can simple fire each hour (only with the constants) or 4-5 hours.

    Note: I already tested every single feature you add for the Android version and works perfectly. Later when I got time I’ll try myself to fix the costum sounds and icons and share my solution.

    Like

    1. Thanks, I’m sure everybody will be glad with this feature. Also as I said at the post even though I haven’t program for Android before I managed to make minor changes here and there, but Resources was something I just couldn’t grasp with this lack of knowledge and time.

      Like

  13. Costum icons and sounds:
    I’m not a Java Android developer but from a search, seems easy to read image from SD card: http://stackoverflow.com/questions/12652798/loading-drawable-from-sd-card

    A little more difficult but not impossilble to read mp3 from SD card: http://android-er.blogspot.pt/2010/07/play-mp3-in-sd-card-using-androids.html

    So perhaps the developer could set imagePath and soundPath on the notification and would be his responsibility to ensure that this image/sound exists on that particular path (another aproach would be the ANE automatically copy the file to SD Card on somehere (Android/data/your_ane_name for example).

    Just some ideas 🙂

    Perhaps you, someone or even me could implement this one day to finish this ANE. Even so, I’m using right now 🙂

    Like

  14. Update your description at the top of the page.

    When you said: “The Android version doesn’t support custom sounds and application badge number”

    Should be: “The Android version doesn’t support custom icons and sounds”

    Before also don’t support costum icons but for the other hand supports badge number (at least worked on my device :))

    Like

  15. A suggestion to be considered for a future version and extends the possibilities of this already fantastic ANE:

    Possibility for opening a native dialog box (if a particular flag indicates that the alert should open a dialog box instead of appear on the notification bar) and this box could be in 2 ways:
    – Informative (only the text of the message itself with one button to close – if possible the text of the button also costumizable)
    – Question (text + alert button yes and the other not – if possible also costumizable) that the answer could be sent to a webservice with the id/tag of the message and the response

    Yes, this is very costumizable think and goes belong this ANE but will make this ANE not 5 stars but 10 stars 😀

    Like

    1. Again, I will answer myself. iconType for a bundle of icons 🙂

      It’s missing only costum icons and sounds to be 100% perfect. Even so, very very good job 🙂

      Like

  16. Nice work. I’ll test today!

    Some questions (Android version):
    – Can I schedule to run several Alerts or every new alert will override the previous one ?
    – It’s possible to pass some tag to the alert and then to the app thru invoke. What I want to be able to do is to know that the app was opened by the alert and what kind of alert (definied by me) was ?
    – This works when the app is open in foreground ?
    – This works when the app is open in background ?

    Like

    1. Hey Hugo:
      – You can schedule several Alerts without overriding the previous one, just use a different id in notifyUser method.
      – In the notification you have an actionData property which you can set to a generic Object with any data in it.
      This data can be retrieved by using the NotificationEvent object actionData property.
      – It works when the app is open in foreground and in background. The only catch is that when the app is visible
      the notification will not appear but the NotificationEvent will trigger.

      Also I tried to use custom sound and icons but I found some issues with that. Maybe on a future version yes.

      Like

      1. I Juan,

        I already tryed your ANE (Android version) and it’s a very, very good work.
        Very stable. Clean and well documented source code and you make a comum class between Android and iOS without need 2 ANE’s.

        In less than 3 minutes and without knowledge about your ANE, I could test myself and clear my questions.

        If on a future version we can use costum icons and sounds then I would say that this is 100% perfect local notification ANE, no question about that, but with the native icons and continuos vibration (when I really, really want that the user knows) we have nowadays a workaround 🙂

        Congratulations on this wonderful piece of software.

        Like

  17. Hey thanks for much for this ANE. It’s great.

    I have an issue though. I set notifications perfectly, and have a function to handle notifications when the application is resumed (by clicking on a notification). 2 things:

    – Can i set the default notification type to Alert?
    – If the app is already running then instead of throwing a notification the app automatically runs the notification handler function. Any way to avoid this?
    – Any way to get notification repeat to work on Droid?

    Cheers!

    Like

  18. Hi.
    unfortunately the notifications are killed on Android when the device is rebooted.
    Is there any way to persist notifications on Android? On iOS rebooting is no problem.

    Thanks in advance!

    Like

  19. Hi,
    thanks for this nice ane! Works great on iOS devices. On Android, I have one (big) problem:
    Works on Samsung S3, Samsung SPlus, Sony Tablet S, but app crashes on Asus Transformer TF300T.

    Anyone who knows about this problem?

    Regards
    Stefan

    Like

  20. Thanks a lot for this ANE! But I having a problem on my iOS project, I added the ANE and get no error, but it does not work ether.. The event NOTIFICATION_ACTION is never called, what could be happening?

    Like

    1. The NotificationEvent.NOTIFICATION_ACTION event is only dispatched when the user unlock the Iphone when a alert is fired or when a notification is clicked on the notification panel.

      Like

  21. Thank you very much! That’s what I have been looking for, because the badge via push notifications (APN) is reset every time when you launch the app. With your extension I can set the badge to the correct value even if you exit the app. Yeah!
    Thomas

    Like

  22. Hi,

    if I import your ANE into FlashBuilder 4.7 i get the following Error:
    “This ANE does not support Desktop(Mac) platform”
    at Flex Build Path->Native Extensions

    The same import in FlashBuilder 4.6 works properly.

    Thx for help!

    Like

  23. Hi, i have been playing with this all day and cannot figure out (from the sample) how to increment the notification.numberAnnotation at runtime.
    I have a repeatInterval set for every minute (just as a proof of concept)

    anybody advise please

    Thanks

    Like

    1. Hi Nick. I agree with you because I also don’t know how to increment badge number when receiving more notifications. I still see only ‘1’.

      Like

      1. Got the same problem. I try :

        notification.numberAnnotation = notificationManager.applicationBadgeNumber + 1;

        and

        notification.numberAnnotation = notification.numberAnnotation + 1;

        Like

  24. Thanks a lot for that. Local Notifications with fire dates were missing on iOS with Air.
    I have developped an Android ANE which allow to keep alive the app (by providing an Android Service), like Skype. So, the app runs everytime and can send local notifications at any moment, and can also keep a network socket connection alive, for example. I’ll post it if somebody is interested in.

    Like

    1. Hi Tezqa, I would like to know if this ANE with Android service is what I am looking for. Is the service not a heavy hit on battery life?

      I would like to send a local notification once a month for 6 months ( from installation date).

      Like

  25. For the people trying to run the shell scripts I provide in the source code, you need to do it on Mac (PC versions will be available soon), and you need to open this files in a text editor and change the paths at the beginning to point to the right folders. Always make sure you have the latest version by downloading source code again.

    Like

    1. Looking forward to that. For some reason I can’t get notifications set in the future to show if the app is not running. And from my understanding that should work, right?

      It works great on iOS though 🙂

      Like

    2. Instead of writing a new post I updated this one. Just note I have changed the [AppName]-app.xml file description. This file now has a new android tag with some services needed for the Android app to work. Give it a try!

      Like

  26. Works great on iOS! Good job!!

    Negative:

    1) Didn’t work for me on Android. Tried:

    extension ID = com.juankpro.ane.LocalNotification
    service android:name=”com.juankpro.ane.localnotif.LocalNotificationIntentService”

    2) Weird: import com.juankpro.ane.localnotif.* doesn’t work for some strange reason but explicit import is ok, like:

    import com.juankpro.ane.localnotif.NotificationManager;
    import com.juankpro.ane.localnotif.Notification;
    import com.juankpro.ane.localnotif.NotificationEvent;
    etc…

    Like

    1. The samples in the BitBucket/Git repository have all what’s needed for it to work. Try downloading again if you want, from time to time I make changes so its a good idea to always download the latest version. Once downloaded look at the apps xml files and see what you can copy from there.

      Like

      1. I also got it working great on iOS and yet couldn’t seem to get it working on Android at first. My problem was I hadn’t added the new receiver for the Alarm Service.

        In case it helps someone else (I am using FB 4.6):

        (Note that this is already in the LocalNotificationTest-app.xml file provided – but I missed it!).

        Thanks for the very useful ANE!

        Like

  27. Hello I have a question about the library :
    The way I understand it is for IOS when a AIR app is place in the background the app is suspended. Meaning if the app has a timer to check lets say a web services that timer won’t fire. So the your library won’t work in that scenario is that correct?

    Like

    1. Of course it will fire. In this case you don’t need to set the fireDate property, but mark your app as running in the background. Apple is used to refuse apps that have no significant reason to be in the background though. They expect you to use other approaches instead. For example for the “message from Web service” feature they prefer you to use Push Notifications. And no, in that case this component doesn’t handles push notifications. As good news AIR 3.4 actually added support for Push Notifications.

      Like

  28. Hi,
    I am trying to do this tutorial with flash cs6 and air 3.4. to my current ios project. My problem is that i get tons of errors when i add this class “FlaSample” to the stage and press “publish”. It gives me errors like:
    Scene 1, Layer ‘styles’, Frame 1, Line 5 1046: Type was not found or was not a compile-time constant: TextFormat. Scene 1, Layer ‘Actions’, Frame 3, Line 99 1046: Type was not found or was not a compile-time constant: NetworkInterface.

    When i take this “FlaSample” away from the “Class” field, everything works fine again and i can publish my project to my iPad (while that ane file is stille defined in the library). So is there any other way to do this without using this “class” and external “as” -file ?? Can someone give me example of code which i could just put to my project frame 1 without external as -file ??

    Like

    1. Which version of Flash are you using. On Flash CS 5.5 you cannot publish directly to iOS if you use ANEs. You need to Ctrl+enter, ignore the errors, and then package the resulting SWF into an iOS app using AIR.

      Like

  29. 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.

    Like

  30. Does this work on Apple’s iOS simulator? I tried testing this on the simulator and no notifications appeared, but I’m not getting any error messages either.

    Like

    1. I read that to make any ANE work on the simulator the ANE has to be packaged as iPhone-x86 and not as iPhone-ARM. So you might have to recompile the ANE first. I included a shell script to compile the ANE on Mac inside the bin folder. Try changing the platform to iPhone-x86 in the extension.xml file.

      Like

  31. Hey. I have a problem, I tried to compile the sample for adobe cs6 windows 7 64 bit, but I got this error:(screenshot)

    How to solve?

    Like

  32. Hi,
    I have used your Native Extension in a Flash Builder 4.6 project. But when I try to export release build it is giving the following error:

    “Error occured while packaging the application:

    Id: unknown option: -ios_version_min
    Compilation failed while executing : Id64 ”

    I din’t use to get this error before when using Adobe NE. Do I need to configure something in Falsh Builder to use your NE. Your help will be very much appreciated/

    Thanks

    Like

  33. Firstly, thanks for writing and releasing this extension! Unfortunately I’m having a problem where Flash Builder reports Class com.juankpro.ane.localnotif::NotificationManager could not be found. I’m using the sample app supplied in on the bitbucket repository. Any ideas?

    Thanks!

    Like

  34. Hello. I want to use your ANE in my app, but I can’t find license description for this ANE. Please tell me the limitation in distributing app using this ANE in Apple app store. Thanks.

    Like

  35. hi thanks for posting, i tried your version like the adobe notifications ane posted but it doesn’t seem to allow you to relaunch the app from the notification slider on Android phones apparently you need to set the permissions in the app xml description file under manifest –

    .

    Like

    1. doesn’t look like i can post xml code ;0 anyways my question is too i need to change the name of the service for you version? –

      service android:name=”com.adobe.ep.localnotifications.LocalNotificationIntentService”/

      Like

      1. As I wrote, I don’t how to program for Android, and if the original author of the ANE (Daniel), associated namespaces between Java and ActionScript, it might have stopped working on Android. The Android version is untouched so it doesn’t have any improvements or additions. Hence, if you’re just going to compile for Android, I recommend getting the original version from Daniel.

        Like

        1. thanks for your great work juankpro but ane is not working for Andriod (for iPhone it’s working fine). I have taken ane file from “Downloaded Folderjuankpro-jklocalnotifications-ane-59393855dee5juankpro-jklocalnotifications-ane-59393855dee5bin” directory.
          Kindly tell me how I can use ane for Andriod?
          And is there any possibility to run it on Blackbarry, Symbians etc?

          Like

  36. it doesn’t work fine on my iPhone. When i enter the game, it crash! I don’t know why. Is there anything wrong with my signature? Does the ANE need to be signed?

    Like

    1. Yes, sadly as you can read at the top of the previous post and at the title of the current post, I did it only for iOS because I don’t know anything about Android yet. So the android version doesn’t have the time additions as well as some other additions. I might try to add them even with just a basic knowledge on Android in the future. But not sure when. I’m going to repeat the previous post explanation here to make it clear for other people as well.

      Like

  37. Hmm it works not bot in the way i would like it. Using the example app en sending a notification it should trigger after 15 sec right ? but it triggers at ones. Btw this is on android.

    Like

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