融云SDK版本:4.0.0.3
极光SDK版本:3.6.8
记得是这两个版本,或者看下极光,融云最新文档对华为版本的支持是不是一致,要不然你解决jar,清单配置等一系列问题就头疼了,而且明确说是解决不了的。
配置
因为极光中已经有com.huawei.android.hms:base,所以app.build只需要引入
implementation 'com.huawei.hms:push:4.0.2.300'
清单配置
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="你的华为的appid" />
<!-- BridgeActivity定义了HMS-SDK中一些跳转所需要的透明页面-->
<activity
android:name="com.huawei.hms.activity.BridgeActivity"
android:configChanges="orientation|locale|layoutDirection|fontScale|screenSize|smallestScreenSize|screenLayout"
android:excludeFromRecents="true"
android:exported="false"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent" >
<meta-data
android:name="hwc-theme"
android:value="androidhwext:style/Theme.Emui.Translucent" />
</activity>
<provider
android:name="com.huawei.hms.update.provider.UpdateProvider"
android:authorities="${APPLICATIONID}.hms.update.provider"
android:exported="false"
android:grantUriPermissions="true">
</provider>
<!--这个已经不需要-->
<!--<receiver android:name=".im.push.HWPushReceiver" android:exported="false">-->
<!--<intent-filter android:priority="0x7fffffff">-->
<!--<!– 必须,用于接收token –>-->
<!--<action android:name="com.huawei.android.push.intent.REGISTRATION" />-->
<!--<!– 必须,用于接收消息 –>-->
<!--<action android:name="com.huawei.android.push.intent.RECEIVE" />-->
<!--<!– 可选,用于点击通知栏或通知栏上的按钮后触发onEvent回调 –>-->
<!--<action android:name="com.huawei.android.push.intent.CLICK" />-->
<!--<!– 可选,查看push通道是否连接,不查看则不需要 –>-->
<!--<action android:name="com.huawei.intent.action.PUSH_STATE" />-->
<!--</intent-filter>-->
<!--</receiver>-->
<service android:name=".im.push.HWPushService" android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="cn.jpush.android.service.PluginHuaweiPlatformsService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
<!--华为推送配置结束-->
记得PluginHuaweiPlatformsService极光的也要注册,否则极光的推送收不到
还有最重要的点
极光的Rest Api需要配置third_party_channel的"huawei":{"distribution":"secondary_push"}
这样设置为了一个需求app后台运行,点击通知栏能跳转到相应界面。app不运行的情况下,启动应用即可
网友评论