本文链接:http://blog.csdn.net/kongxx/article/details/8181196
上一篇文章说到了怎样通过helium来推送通知,下面来看看怎样通过Google的GCM来推送。
这里关于GCM的配置可以参考http://developer.android.com/guide/google/gcm/demo.html
下面的例子假定已经配置好了Google的GCM。
1. 首先添加gcm.jar包到libs目录下,并将其加入classpath。
2. 首先修改AndroidManifest.xml文件,添加对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 -->
<application
android: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" />
<receiver
android: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. 修改assets/airshipconfig.properties文件
3.1 将其中的
transport=helium
改成
transport = gcm
3.2 将其中的gcmSender设置为Google API project ID。
4. 运行程序测试,从Urban AirShip向此设备发送通知,然后检查状态栏。
分享到:
相关推荐
出口 UrbanAirship.com | 导入 PushWoosh.com 用于从 UrbanAirship 导出设备令牌并导入 PushWoosh 推送通知服务的基于 Go 的脚本。 遗憾的是 PushWoosh 没有批量导入 API,所以我制作了这个脚本。 使用 goroutine 和...
按照mParticle Android SDK入门,然后重新构建并启动您的应用程序,并验证adb logcat的输出中是否看到"Urban Airship detected" 。 请参考下面的mParticle的集成文档以启用集成。 如果您希望利用Urban Airship的...
资源来自pypi官网。 资源全名:airship_steamcloud-1.3-py2.py3-none-any.whl
资源来自pypi官网。 资源全名:airship_icloud-1.3.3-py2.py3-none-any.whl
Urban Airship Android云台适配器 Urban Airship Gimbal Adapter是一个嵌入式类,允许用户将Gimbal Place事件与Urban Airship集成在一起。 资源 安装 要安装它,请将以下依赖项添加到应用程序的build.gradle文件中:...
NULL 博文链接:https://fanfq.iteye.com/blog/1673878
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用