• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

AIR 3.4 + iOS 5.1 Push Notifications - Tips and Tricks

Participant ,
Jul 21, 2012 Jul 21, 2012

Copy link to clipboard

Copied

Hey Guys,

So I finally got push notifications going on iOS and I'm thrilled. Here's some issues I ran into that will help you folks out with the example code they are giving here: http://blogs.adobe.com/airodynamics/2012/05/29/push-notifications-support-in-ios/

1.) The release notes are not valid.

import flash.notifications;

   Should Be:

import flash.notifications.*;

if (RemoteNotifier.supportedNotificationStyles() != NULL) {

   Should Be:

if (RemoteNotifier.supportedNotificationStyles != null) {

subscribeOptions.notificationStyle = preferredNotificationStyles;

   Should Be:

subscribeOptions.notificationStyles = preferredNotificationStyles;

2.) The three variables needed to subscribe to the APN should be declaried in the class body not scoped function local:

   private var _preferredNotificationStyles : Vector.<String>;

   private var _remoteNotifier : RemoteNotifier = new RemoteNotifier();

   private var _subscribeOptions:RemoteNotifierSubscribeOptions;

3.) When Flash Builder creates the debug version of the app.xml file located in bin-debug/[appname]-app.xml , it changes the application id to end in .debug. So com.examplecompany.exampleapplication.debug  This will prevent the APNS from sending the alert right. So you have to edit the app.xml build file, in the bin-debug folder, and change the name back without the .debug. You'll probably get a 'derived' warning which is ok. If you ever do something that updates the app.xml file located in the src folder, I'd recommend deleting the bin-debug folder, run clean, rebuild and then re-edit the app.xml located in the debug folder.

4.) You need an application-identifier key in the entitlements section of the app.xml file. This needs to have the full legal app id which contains the key. see below:

<Entitlements>

            <![CDATA[

                <key>get-task-allow</key>

                <true/>

                <key>aps-environment</key>

                <string>development</string>

                <key>application-identifier</key>

                <string>QVRKBH67LJ.com.kiwiworks.cnn</string>

                <key>keychain-access-groups</key>

                <array>

                    <string>QVRKBH67LJ.com.kiwiworks.cnn</string>

                </array>

            ]]>

        </Entitlements>

5.) Regarding your push service server - I'm not sure if it doesn't work for all of them, but I was unable to send the message request to the push service from my own local computer. It only worked on my remote PHP server. The key was identical.

Error I got locally:

Start Time: 1342873453
Timeout   : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)

What I got when remote:

Start Time: 1342867957
Timeout   : 300 (sec)
Verify return code: 0 (ok)

I'll be writing up this entire 2 weeks of work into a blog post soon. Since 3.4 dropped a couple days ago, most of my work is mute, however I did learn a shit ton about extensions, XCode, ObjC and how to do a full compile ant task ( XCode, Extensions, Packaging, Air Building and iOS device loading/unloading of the app). That alone has reduced the process of building with iTunes by like 60-80 seconds per build at worst. So thankful for the new functionality. 

Let me know if you have any questions and I'll try to answer them.

TOPICS
Development

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 22, 2012 Jul 22, 2012

Copy link to clipboard

Copied

I'm writting a tutorial now but does anyone want the source code to make an iOS app and a PHP/MySQL web service that will demo the functionality?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

LATEST

Hi Pete,

To package your app with a provisioning profile (enabled with Apple Push Notifications Services) you don't have to provide the application identifier and keychain-access-groups in the entitlements .Just the following entitlements will work :

<Entitlements>

            <![CDATA[

                       <key>aps-environment</key>

                       <string>development</string>

            ]]>

</Entitlements>

instead you've to provide the app-id in the <id> tag of the app-xml like just another AIR-iOS app(I know that Flash Builder changes the app-id to "app-name.debug" but you can change it while packaging and one strong reason to recommend this way is that for the testing I have uploaded a test app at app-store to validate these entitlements and Apple has approved it.) in following way:

<id>com.kiwiworks.cnn</key> //Remove the Bundle Seed ID from here.

If you've any questions then please feel free to ask.


-Nimisha

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines