您的位置:首页 > 其它

极光推送和友盟SDK的集成

2013-12-28 11:03 531 查看
最近需要做新的项目,使用了第三方的极光推送,其中不乏周折,在此小总结一下

首先要在极光推送的官网进行注册需要注意两点:

1.你注册的package应该是你android项目的主package,且和Manifest里的一致;

2.获取的Appkey需要正确的添加到Manifest里面;

3.权限问题:一定要把权限添加完整,其中这两个权限一定要都加上

<permission android:name="com.android.newhr.permission.JPUSH_MESSAGE"

android:protectionLevel="signature" />

<uses-permission android:name="com.android.newhr.permission.JPUSH_MESSAGE" />

其次,在项目初始化的时候这两点一定要写对:

JPushInterface.init(this);

JPushInterface.setDebugMode(false); // 设置开启日志,发布时请关闭日志

还有,在极光注册的包名在woekspace中最好不要有重复的,不然会出现启动不同的项目在测试机上会出现同一个项目的运行

最后,如果想接收通知栏和自定义消息Manifest中需要添加完整极光要求的service和receiver

<service

android:name="cn.jpush.android.service.PushService"

android:enabled="true"

android:exported="false">

<intent-filter>

<action android:name="cn.jpush.android.intent.REGISTER" />

<action android:name="cn.jpush.android.intent.REPORT" />

<action android:name="cn.jpush.android.intent.PushService" />

<action android:name="cn.jpush.android.intent.PUSH_TIME" />

</intent-filter>

</service>

<!-- Required SDK核心功能-->

<receiver

android:name="cn.jpush.android.service.PushReceiver"

android:enabled="true" >

<intent-filter android:priority="1000">

<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!--Required 显示通知栏 -->

<category android:name="com.android.newhr" />

</intent-filter>

<intent-filter>

<action android:name="android.intent.action.USER_PRESENT" />

<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />

</intent-filter>

<!-- Optional -->

<intent-filter>

<action android:name="android.intent.action.PACKAGE_ADDED" />

<action android:name="android.intent.action.PACKAGE_REMOVED" />

<data android:scheme="package" />

</intent-filter>

</receiver>

<!-- Required SDK核心功能-->

<receiver android:name="cn.jpush.android.service.AlarmReceiver" />

<receiver

android:name="com.android.newhr.MyReceiver"

android:enabled="true">

<intent-filter>

<action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用户注册SDK的intent-->

<action android:name="cn.jpush.android.intent.UNREGISTRATION" />

<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用户接收SDK消息的intent-->

<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的intent-->

<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!--Required 用户打开自定义通知栏的intent-->

<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" /> <!--Optional 用户接受Rich Push Javascript 回调函数的intent-->

<category android:name="com.android.newhr" />

</intent-filter>

</receiver>

<!-- Required . Enable it you can get statistics data with channel -->

<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>

<meta-data android:name="JPUSH_APPKEY" android:value="your APPkey“
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: