Link: http://blog.csdn.net/kongxx/article/details/8181196
In the previous article, we talked about how to push notifications through helium. Next we will look at how to push notifications through Google GCM.
Here GCM configuration can refer to the http://developer.android.com/guide/google/gcm/demo.html
The following example assumes that Google's GCM has been configured.
1. First add the GCM. jar package to the libs directory and add it to the classpath.
2. First modify the androidmanifest. xml file to add support for GCM.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="urbanairship.client"android:versionCode="1"android:versionName="1.0" >...<!-- BEGIN for Urban Airship GCM --><uses-permission android:name="android.permission.GET_ACCOUNTS" /><uses-permission android:name="android.permission.WAKE_LOCK" /><uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /><uses-permission android:name="urbanairship.client.permission.C2D_MESSAGE" /><permission android:name="urbanairship.client.permission.C2D_MESSAGE" android:protectionLevel="signature" /><!-- END for Urban Airship GCM --><applicationandroid:name="urbanairship.client.MyApplication"android:enabled="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" android:debuggable="true">...<!-- BEGIN for Urban Airship GCM --><receiver android:name="com.urbanairship.CoreReceiver" /><receiverandroid:name="com.urbanairship.push.GCMPushReceiver"android:permission="com.google.android.c2dm.permission.SEND" ><intent-filter><action android:name="com.google.android.c2dm.intent.RECEIVE" /><action android:name="com.google.android.c2dm.intent.REGISTRATION" /><category android:name="urbanairship.client" /></intent-filter></receiver><!-- END for Urban Airship GCM -->...</application></manifest>
3. Modify the assets/airshipconfig. properties file.
3.1 place
transport=helium
Change
transport = gcm
3.2 set gcmsender to the Google API Project ID.
4. Run the program test, send a notification from urban airship to this device, and then check the status bar.