This is an Air native extension for sending push notifications on iOS and Android. It has been developed by FreshPlanet and is used in the game SongPop.
On iOS devices, this ANE uses Apple Push Notification Services. On Android devices, it uses Google Cloud Messaging (GCM).
The ANE binary (AirPushNotification.ane) is located in the bin folder. You should add it to your application project's Build Path and make sure to package it with your app (more information here).
On Android, you might want to update the content of the android/res folder with your own assets. You should also update your android manifest:
```
<!-- Only this application can receive the messages and registration result -->
<permission android:name="INSERT.APP.ID.HERE.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="INSERT.APP.ID.HERE.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- The following lines have to placed inside the <application> tag-->
<receiver android:name="com.freshplanet.nativeExtensions.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="INSERT.APP.ID.HERE" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="INSERT.APP.ID.HERE" />
</intent-filter>
</receiver>
<!-- Local notification -->
<service android:name="com.freshplanet.nativeExtensions.LocalNotificationService"/>
<receiver android:name="com.freshplanet.nativeExtensions.LocalBroadcastReceiver" android:process=":remote"></receiver>
```
and replace INSERT.APP.ID.HERE by your application id ( tag in your manifest).
In order to register the device for a push notifications, you should use the following method:
PushNotification.getInstance().registerForPushNotification(GOOGLE_PROJECT_ID);
The argument GOOGLE_PROJECT_ID is necessary only on Android and is your project's ID on GCM. On iOS, you can call the method with no parameter.
Once the user has given his permission, the following event is triggered:
PushNotificationEvent.PERMISSION_GIVEN_WITH_TOKEN_EVENT
Should you need to edit the extension source code and/or recompile it, you will find an ant build script (build.xml) in the build folder:
cd /path/to/the/ane/build
mv example.build.config build.config
#edit the build.config file to provide your machine-specific paths
ant
This ANE has been written by Thibaut Crenn. It belongs to FreshPlanet Inc. and is distributed under the Apache Licence, version 2.0.