first commit
Change-Id: Ib7c2ab10a2562044fcaf9879388a6cbc1db6ac61
This commit is contained in:
78
荣耀推送配置内容.txt
Normal file
78
荣耀推送配置内容.txt
Normal file
@@ -0,0 +1,78 @@
|
||||
配置Manifest文件
|
||||
配置通知栏消息权限
|
||||
如果您需要在Android 13及以上的荣耀设备上展示通知栏消息,需要申请通知栏权限。
|
||||
|
||||
<manifest ...>
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
</manifest>
|
||||
配置AppId信息
|
||||
您需要在AndroidManifest.xml文件下,添加meta-data标签,并在com.hihonor.push.app_id下添加您的 AppId(AppId在注册完成后获取),用于配置您的设备。
|
||||
|
||||
<manifest ...>
|
||||
<application>
|
||||
<meta-data
|
||||
android:name="com.hihonor.push.app_id"
|
||||
android:value="您的AppId" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
创建消息接收服务
|
||||
HonorMessageService是用于接收新PushToken和接收透传消息的服务。
|
||||
|
||||
继承HonorMessageService并且重写onNewToken方法和onMessageReceived方法。
|
||||
|
||||
public class MyHonorMsgService extends HonorMessageService {
|
||||
//Token发生变化时,会以onNewToken方法返回
|
||||
@Override
|
||||
public void onNewToken(String pushToken) {
|
||||
// TODO: 处理新token。
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(HonorPushDataMsg msg) {
|
||||
// TODO: 处理收到的透传消息。
|
||||
}
|
||||
}
|
||||
注意:
|
||||
由于onNewToken会在init方法设置为true时回调。建议增加网络权限校验和用户同意协议校验。
|
||||
如果透传消息传递敏感的信息:如个人身份证、金钱、银行卡信息、关键业务指令等,建议您对消息内容进行加密处理,进一步进行安全防护。
|
||||
|
||||
注册服务
|
||||
您需要在AndroidManifest.xml文件的application标签下注册您自己的service。
|
||||
|
||||
exported属性需要设置为false,限制其他应用的组件唤醒该service。
|
||||
<manifest ...>
|
||||
<application>
|
||||
<service
|
||||
android:name="com.hihonor.push.sdk.demo.service.MyHonorMsgService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.hihonor.push.action.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
如果您的应用targerSdkVersion大于等于30,需要在 AndroidManifest.xml 中添加标签,用于查找到对应的action。
|
||||
|
||||
<manifest ...>
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="com.hihonor.push.action.BIND_PUSH_SERVICE" />
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
配置混淆脚本
|
||||
您编译APK前需要配置混淆配置文件,避免混淆PushSDK导致功能异常。
|
||||
|
||||
在应用级根目录下打开混淆配置文件proguard-rules.pro,加入排除PushSDK的混淆配置脚本。
|
||||
|
||||
-ignorewarnings
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes Exceptions
|
||||
-keepattributes InnerClasses
|
||||
-keepattributes Signature
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
-keep class com.hihonor.push.**{*;}
|
||||
上一篇
|
||||
集成SDK
|
||||
Reference in New Issue
Block a user