|
Air Native Extension for Push Notifications (iOS + Android) 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. Push NotificationsOn iOS devices, this ANE uses Apple Push Notification Services. On Android devices, it uses Google Cloud Messaging (GCM). InstallationThe 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).UsageIn 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
复制代码 Build scriptShould 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
复制代码 AuthorsThis ANE has been written by Thibaut Crenn. It belongs to FreshPlanet Inc. and is distributed under the Apache Licence, version 2.0.
相关链接:
https://github.com/shvilam/ParseAneTest
下载:
百度云下载
|