账号【谢总@asp.citic.com】【icitic52818888】
应用包名:com.bqt.push
APP ID:100257971
集成步骤
1、注册成为开发者
2、
登录,创建应用
点击“会员中心”,“创建产品”,在“创建产品”页面选择“移动应用”,创建新的应用。
填写移动应用的基本信息:应用名称、应用类型和默认语言,点击“上传APK”或者“产品详情”,完成产品创建。
3、生成证书指纹
- 打开命令行工具,执行cd命令进入keytool.exe所在的目录:
cd C:\Program Files\Java\jdk1.8.0_92\bin
1
1
1
cd C:\Program Files\Java\jdk1.8.0_92\bin
- 获取对应的SHA256指纹
keytool -list -v -keystore C:\_zxwk\zxwlke.keystore
1
1
1
keytool -list -v -keystore C:\_zxwk\zxwlke.keystore
- 获取的信息
密钥库类型: JKS
密钥库提供方: SUN
您的密钥库包含 1 个条目
别名: zxwk
创建日期: 2014-11-21
条目类型: PrivateKeyEntry
证书链长度: 1
证书[1]:
所有者: CN=zxwk, OU=zxwk, O=zxwk, L=wuhan, C=CN
发布者: CN=zxwk, OU=zxwk, O=zxwk, L=wuhan, C=CN
序列号: 546ede5e
有效期开始日期: Fri Nov 21 14:40:30 CST 2014, 截止日期: Sun Oct 28 14:40:30 CST 2114
证书指纹:
MD5: DD:C9:E3:2A:77:D3:21:05:A4:C6:20:2F:EB:75:65:5C
SHA1: DA:FF:CF:09:E9:59:32:39:E7:0D:22:C5:3A:1C:CD:C8:9B:19:FC:7A
SHA256: 6D:3C:C4:74:46:E4:A4:27:4D:5F:97:53:E6:8D:EE:41:7F:FE:88:92:80:DE:02:F9:2B:76:76:92:E2:80:34:F8
签名算法名称: SHA1withRSA
版本: 3
20
20
1
密钥库类型: JKS
2
密钥库提供方: SUN
3
4
您的密钥库包含 1 个条目
5
6
别名: zxwk
7
创建日期: 2014-11-21
8
条目类型: PrivateKeyEntry
9
证书链长度: 1
10
证书[1]:
11
所有者: CN=zxwk, OU=zxwk, O=zxwk, L=wuhan, C=CN
12
发布者: CN=zxwk, OU=zxwk, O=zxwk, L=wuhan, C=CN
13
序列号: 546ede5e
14
有效期开始日期: Fri Nov 21 14:40:30 CST 2014, 截止日期: Sun Oct 28 14:40:30 CST 2114
15
证书指纹:
16
MD5: DD:C9:E3:2A:77:D3:21:05:A4:C6:20:2F:EB:75:65:5C
17
SHA1: DA:FF:CF:09:E9:59:32:39:E7:0D:22:C5:3A:1C:CD:C8:9B:19:FC:7A
18
SHA256: 6D:3C:C4:74:46:E4:A4:27:4D:5F:97:53:E6:8D:EE:41:7F:FE:88:92:80:DE:02:F9:2B:76:76:92:E2:80:34:F8
19
签名算法名称: SHA1withRSA
20
版本: 3
4、申请PUSH服务
登录“华为开发者联盟”,点击“会员中心”,
在“我的产品”页面,选择创建的应用,进入产品详情页面,点击产品服务列表的“+”号添加PUSH服务。
在配置信息界面填写应用包名、回调地址、SHA256指纹,
应用包名必须和APK包名保持一致,且不可更改。
回调地址配置后可修改。
5、获取PUSH服务参数
开发者为APP开通PUSH服务后,华为方会分配服务参数,用于开发者集成HMS SDK时使用。获取服务参数操作如下。
登录“华为开发者联盟”,
选择“会员中心 > 我的产品”,点击产品名称,进入指定的产品页面。
点击“移动应用详情”链接,在弹出的“移动服务详情”对话框获取服务参数。
产品名称:测试
应用包名:com.bqt.push
APP ID:100257971 applicationID,华为开发者联盟为APP分配的唯一标识
APP SECRET:785bf3e10d53b0420b79a6c2ef97981a 应用秘钥,在开发PUSH 服务端时需要用到此参数
4
4
1
产品名称:测试
2
应用包名:com.bqt.push
3
APP ID:100257971 applicationID,华为开发者联盟为APP分配的唯一标识
4
APP SECRET:785bf3e10d53b0420b79a6c2ef97981a 应用秘钥,在开发PUSH 服务端时需要用到此参数
开发前自检
参数 | 类型 | 来源 | 意义 |
Keystore-file | 文件 | 自行创建 | Android应用签名文件,和华为开发者联盟申请应用服务时填写的签名文件指纹匹配 |
Appid | 字符串 | 开发者联盟网站应用服务详情 | 开发者联盟给应用分配的唯一标识 |
应用包名 | 字符串 | 开发者联盟网站创建应用时填写的包名 | Android应用的包名要与这个包名一致 |
APP SECRET | 字符串 | 开发者联盟,“移动应用详情”界面 | PUSH 服务端开发时发送消息需要 |
简洁版自定义消息推送Demo
获取需要的SDK
1、去
官网 下载 HMS Agent套件(必选)
这货是非常非常非常坑爹的,我日你个巴拉!下载之后会发现里面杂七杂八什么都系都有,有华为支付、华为账号、华为...等所有华为开放的服务,而且还是一个module!麻辣隔壁的,我就用一个推送(其他推送SDK只需写一个广播接受者就可以了),你这货让我导入这么多东西怎么能忍!更坑爹的是,里面common包下有十几个文件,这是所有服务通用的包,就算把其他服务去掉,只有这是几个类这也是不能忍的!
2、运行
Agent下的【GetHMSAgent.bat】文件
草你麻痹的,我移了半天,越搞错误越多,完全不能忍!这时就仔细看了下解压包根目录那一坨坨都是些什么垃圾东西,结果发现了新大陆!
点击运行
GetHMSAgent.bat文件可以从全量的 HMSAgent 代码,根据您的选择删除不需要的代码!
这些爽翻了!
不过用的时候要注意,运行过程会让你输入cpid,我们没有这玩意,随意输几个就可以了。
3、运行后我们只需把 hms 包移到我们的项目中就可以了。
初始化
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
boolean success = HMSAgent.init(this);
Log.i("bqt", ""+success);
}
@Override
public void onTerminate() {
super.onTerminate();
HMSAgent.destroy();
}
}
15
15
1
public class App extends Application {
2
3
public void onCreate() {
4
super.onCreate();
5
boolean success = HMSAgent.init(this);
6
Log.i("bqt", ""+success);
7
8
}
9
10
11
public void onTerminate() {
12
super.onTerminate();
13
HMSAgent.destroy();
14
}
15
}
Activity
public class HuaweiPushActivity extends ListActivity {
public static boolean isForeground = false;
private TextView tv;
private String[] array;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tv = new TextView(this);
tv.setTextColor(Color.BLUE);
getListView().addFooterView(tv);
array = new String[]{"获取token",
"删除token",
" 获取push状态",
"设置是否接收普通透传消息",
"设置接收通知消息",
"显示push协议",};
setListAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new ArrayList<>(Arrays.asList(array))));
EventBus.getDefault().register(this);
}
private boolean b;
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
tv.append("\n" + array[position] + " ");
b = !b;
switch (position) {
case 0:
HMSAgent.Push.getToken((rst) -> tv.append("+rst"));
break;
case 1://token=0990005841682350300001697200CN01 belongId=1
String token = getSharedPreferences("huawei_token", Context.MODE_PRIVATE).getString("token", null);
HMSAgent.Push.deleteToken(token, rst -> tv.append("" + rst));
break;
case 2:
HMSAgent.Push.getPushState(rst -> tv.append("" + rst));
break;
case 3:
HMSAgent.Push.enableReceiveNormalMsg(b, rst -> tv.append(b + " " + rst));
break;
case 4:
HMSAgent.Push.enableReceiveNotifyMsg(b, rst -> tv.append(b + " " + rst));
break;
case 5:
HMSAgent.Push.queryAgreement(rst -> tv.append("" + rst));
break;
}
}
@Override
protected void onResume() {
isForeground = true;
super.onResume();
}
@Override
protected void onPause() {
isForeground = false;
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPushEvent(BasePushBean bean) {
TextView tv = new TextView(this);
tv.setTextColor(Color.BLUE);
tv.setText(bean.msg);
getListView().addFooterView(tv);
}
}
77
1
public class HuaweiPushActivity extends ListActivity {
2
3
public static boolean isForeground = false;
4
5
private TextView tv;
6
private String[] array;
7
8
protected void onCreate(Bundle savedInstanceState) {
9
super.onCreate(savedInstanceState);
10
tv = new TextView(this);
11
tv.setTextColor(Color.BLUE);
12
getListView().addFooterView(tv);
13
array = new String[]{"获取token",
14
"删除token",
15
" 获取push状态",
16
"设置是否接收普通透传消息",
17
"设置接收通知消息",
18
"显示push协议",};
19
setListAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new ArrayList<>(Arrays.asList(array))));
20
EventBus.getDefault().register(this);
21
}
22
23
private boolean b;
24
25
26
protected void onListItemClick(ListView l, View v, int position, long id) {
27
tv.append("\n" + array[position] + " ");
28
b = !b;
29
switch (position) {
30
case 0:
31
HMSAgent.Push.getToken((rst) -> tv.append("+rst"));
32
break;
33
case 1://token=0990005841682350300001697200CN01 belongId=1
34
String token = getSharedPreferences("huawei_token", Context.MODE_PRIVATE).getString("token", null);
35
HMSAgent.Push.deleteToken(token, rst -> tv.append("" + rst));
36
break;
37
case 2:
38
HMSAgent.Push.getPushState(rst -> tv.append("" + rst));
39
break;
40
case 3:
41
HMSAgent.Push.enableReceiveNormalMsg(b, rst -> tv.append(b + " " + rst));
42
break;
43
case 4:
44
HMSAgent.Push.enableReceiveNotifyMsg(b, rst -> tv.append(b + " " + rst));
45
break;
46
case 5:
47
HMSAgent.Push.queryAgreement(rst -> tv.append("" + rst));
48
break;
49
}
50
}
51
52
53
protected void onResume() {
54
isForeground = true;
55
super.onResume();
56
}
57
58
59
protected void onPause() {
60
isForeground = false;
61
super.onPause();
62
}
63
64
65
protected void onDestroy() {
66
super.onDestroy();
67
EventBus.getDefault().unregister(this);
68
}
69
70
(threadMode = ThreadMode.MAIN)
71
public void onPushEvent(BasePushBean bean) {
72
TextView tv = new TextView(this);
73
tv.setTextColor(Color.BLUE);
74
tv.setText(bean.msg);
75
getListView().addFooterView(tv);
76
}
77
}
Receiver
public class HuaweiPushRevicer extends PushReceiver {
/**
* 这里接收到穿透消息,自定义通知栏,和操作
*
* @param context 上下文
* @param msg 消息
* @param bundle bundle
* @return 不清楚返回真假的作用
*/
@Override
public boolean onPushMsg(Context context, byte[] msg, Bundle bundle) {
try {
String content = new String(msg, "UTF-8");
Log.i("bqt", "华为【onPushMsg】" + content);
PushMsgReceiverHelper.getInstance().onHuaweiPushMsgReceiver(content);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
@Override
public void onToken(Context context, String token, Bundle extras) {
Log.i("bqt", "华为【onToken】token=" + token + " belongId=" + extras.getString("belongId"));
//保存在本地备用
context.getSharedPreferences("huawei_token", Context.MODE_PRIVATE).edit().putString("token", token).apply();
Toast.makeText(context, token, Toast.LENGTH_SHORT).show();
}
/**
* 这里接收到的是通知栏消息,无法自定义操作,默认打开应用
*
* @param context 上下文
* @param event 事件
* @param extras 额外
*/
public void onEvent(Context context, Event event, Bundle extras) {
int notifyId = extras.getInt(BOUND_KEY.pushNotifyId, 0);
String message = extras.getString(BOUND_KEY.pushMsgKey);
Log.i("bqt", "华为【onEvent】event=" + event + " notifyId=" + notifyId + " message=" + message);
if (Event.NOTIFICATION_OPENED.equals(event) || Event.NOTIFICATION_CLICK_BTN.equals(event)) {
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (0 != notifyId && manager != null) {
manager.cancel(notifyId);
}
}
super.onEvent(context, event, extras);
}
/**
* 得到华为推送的连接状态
*
* @param context 上下文
* @param pushState 连接状态
*/
@Override
public void onPushState(Context context, boolean pushState) {
Log.i("bqt", "华为【onPushState】连接状态:" + pushState);
}
}
62
1
public class HuaweiPushRevicer extends PushReceiver {
2
3
/**
4
* 这里接收到穿透消息,自定义通知栏,和操作
5
*
6
* @param context 上下文
7
* @param msg 消息
8
* @param bundle bundle
9
* @return 不清楚返回真假的作用
10
*/
11
12
public boolean onPushMsg(Context context, byte[] msg, Bundle bundle) {
13
try {
14
String content = new String(msg, "UTF-8");
15
Log.i("bqt", "华为【onPushMsg】" + content);
16
PushMsgReceiverHelper.getInstance().onHuaweiPushMsgReceiver(content);
17
} catch (Exception e) {
18
e.printStackTrace();
19
}
20
return false;
21
}
22
23
24
public void onToken(Context context, String token, Bundle extras) {
25
Log.i("bqt", "华为【onToken】token=" + token + " belongId=" + extras.getString("belongId"));
26
//保存在本地备用
27
context.getSharedPreferences("huawei_token", Context.MODE_PRIVATE).edit().putString("token", token).apply();
28
Toast.makeText(context, token, Toast.LENGTH_SHORT).show();
29
}
30
31
/**
32
* 这里接收到的是通知栏消息,无法自定义操作,默认打开应用
33
*
34
* @param context 上下文
35
* @param event 事件
36
* @param extras 额外
37
*/
38
public void onEvent(Context context, Event event, Bundle extras) {
39
int notifyId = extras.getInt(BOUND_KEY.pushNotifyId, 0);
40
String message = extras.getString(BOUND_KEY.pushMsgKey);
41
Log.i("bqt", "华为【onEvent】event=" + event + " notifyId=" + notifyId + " message=" + message);
42
43
if (Event.NOTIFICATION_OPENED.equals(event) || Event.NOTIFICATION_CLICK_BTN.equals(event)) {
44
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
45
if (0 != notifyId && manager != null) {
46
manager.cancel(notifyId);
47
}
48
}
49
super.onEvent(context, event, extras);
50
}
51
52
/**
53
* 得到华为推送的连接状态
54
*
55
* @param context 上下文
56
* @param pushState 连接状态
57
*/
58
59
public void onPushState(Context context, boolean pushState) {
60
Log.i("bqt", "华为【onPushState】连接状态:" + pushState);
61
}
62
}
消息处理类
/**
* 处理华为光推送推过来的自定义消息
*/
public void onHuaweiPushMsgReceiver(String message) {
Log.i("bqt", "【华为推送】" + message);
if (HuaweiPushActivity.isForeground) {
EventBus.getDefault().post(new BasePushBean(message, BasePushBean.TYPE_STRING));
}
}
1
/**
2
* 处理华为光推送推过来的自定义消息
3
*/
4
public void onHuaweiPushMsgReceiver(String message) {
5
Log.i("bqt", "【华为推送】" + message);
6
if (HuaweiPushActivity.isForeground) {
7
EventBus.getDefault().post(new BasePushBean(message, BasePushBean.TYPE_STRING));
8
}
9
}
配置文件
project的
build.gradle
allprojects {
repositories {
google()
jcenter()
maven {url 'http://developer.huawei.com/repo'}//华为maven仓路径
}
}
7
7
1
allprojects {
2
repositories {
3
google()
4
jcenter()
5
maven {url 'http://developer.huawei.com/repo'}//华为maven仓路径
6
}
7
}
module的build.gradle
implementation 'com.huawei.android.hms:push:2.6.0.301'
1
implementation 'com.huawei.android.hms:push:2.6.0.301'
// 签名配置
signingConfigs {
release {
storeFile file("./push.keystore")
storePassword "***"
keyAlias "zxwk"
keyPassword "***"
}
}
x
1
// 签名配置
2
signingConfigs {
3
release {
4
storeFile file("./push.keystore")
5
storePassword "***"
6
keyAlias "zxwk"
7
keyPassword "***"
8
}
9
}
混淆文件:proguard-android.txt
-ignorewarning
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.gamebox.plugin.gameservice.**{*;}
-keep public class com.huawei.android.hms.agent.** extends android.app.Activity { public *; protected *; }
-keep interface com.huawei.android.hms.agent.common.INoProguard {*;}
-keep class * extends com.huawei.android.hms.agent.common.INoProguard {*;}
15
15
1
-ignorewarning
2
-keepattributes *Annotation*
3
-keepattributes Exceptions
4
-keepattributes InnerClasses
5
-keepattributes Signature
6
-keepattributes SourceFile,LineNumberTable
7
-keep class com.hianalytics.android.**{*;}
8
-keep class com.huawei.updatesdk.**{*;}
9
-keep class com.huawei.hms.**{*;}
10
11
-keep class com.huawei.gamebox.plugin.gameservice.**{*;}
12
13
-keep public class com.huawei.android.hms.agent.** extends android.app.Activity { public *; protected *; }
14
-keep interface com.huawei.android.hms.agent.common.INoProguard {*;}
15
-keep class * extends com.huawei.android.hms.agent.common.INoProguard {*;}
AndroidManifest.xml
添加权限:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
5
5
1
<uses-permission android:name="android.permission.INTERNET"/>
2
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
3
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
4
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
5
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
在application节点下增加APPID:
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="appid=100257971"/>
3
3
1
<meta-data
2
android:name="com.huawei.hms.client.appid"
3
android:value="appid=100257971"/>
注册四大组件:
<!-- =============================== 注册Activity =============================== -->
<!-- 使用 HMSAgent 代码接入HMSSDK 需要注册的activity-->
<activity
android:name=".hms.agent.common.HMSAgentActivity"
android:configChanges="orientation|locale|screenSize|layoutDirection|fontScale"
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>
<!-- 接入HMSSDK 需要注册的activity,定义了HMS-SDK中一些跳转所需要的透明页面-->
<activity
android:name="com.huawei.hms.activity.BridgeActivity"
android:configChanges="orientation|locale|screenSize|layoutDirection|fontScale"
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>
<!-- 应用自升级接口所需要使用的页面-->
<activity
android:name="com.huawei.updatesdk.service.otaupdate.AppUpdateActivity"
android:configChanges="orientation|screenSize"
android:exported="false"
android:theme="@style/upsdkDlDialog">
<meta-data
android:name="hwc-theme"
android:value="androidhwext:style/Theme.Emui.Translucent.NoTitleBar"/>
</activity>
<!-- 应用自升级接口所需要使用的页面-->
<activity
android:name="com.huawei.updatesdk.support.pm.PackageInstallerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="false"
android:theme="@style/upsdkDlDialog">
<meta-data
android:name="hwc-theme"
android:value="androidhwext:style/Theme.Emui.Translucent"/>
</activity>
<!-- =============================== 注册Revicer =============================== -->
<!-- 接收Push消息广播,此receiver需要开发者自己创建并继承PushReceiver类-->
<receiver android:name=".HuaweiPushRevicer">
<intent-filter>
<!-- 必须,用于接收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>
<!-- 接收通道发来的通知栏消息 -->
<receiver android:name="com.huawei.hms.support.api.push.PushEventReceiver">
<intent-filter>
<action android:name="com.huawei.intent.action.PUSH"/>
</intent-filter>
</receiver>
<!-- =============================== 注册Provider =============================== -->
<!-- 用于HMS-SDK引导升级HMS,提供给系统安装器读取升级文件,这边 要替换上您应用的包名-->
<provider
android:name="com.huawei.hms.update.provider.UpdateProvider"
android:authorities="com.bqt.push.hms.update.provider"
android:exported="false"
android:grantUriPermissions="true"/>
<!-- 用于应用自升级,这边 要替换上您应用的包名-->
<provider
android:name="com.huawei.updatesdk.fileprovider.UpdateSdkFileProvider"
android:authorities="com.bqt.push.updateSdk.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
</provider>
<!-- =============================== 注册Service =============================== -->
<!-- 应用下载服务,用于应用自升级-->
<service
android:name="com.huawei.updatesdk.service.deamon.download.DownloadService"
android:exported="false"/>
91
91
1
<!-- =============================== 注册Activity =============================== -->
2
<!-- 使用 HMSAgent 代码接入HMSSDK 需要注册的activity-->
3
<activity
4
android:name=".hms.agent.common.HMSAgentActivity"
5
android:configChanges="orientation|locale|screenSize|layoutDirection|fontScale"
6
android:excludeFromRecents="true"
7
android:exported="false"
8
android:hardwareAccelerated="true"
9
android:theme="@android:style/Theme.Translucent" >
10
<meta-data
11
android:name="hwc-theme"
12
android:value="androidhwext:style/Theme.Emui.Translucent" />
13
</activity>
14
<!-- 接入HMSSDK 需要注册的activity,定义了HMS-SDK中一些跳转所需要的透明页面-->
15
<activity
16
android:name="com.huawei.hms.activity.BridgeActivity"
17
android:configChanges="orientation|locale|screenSize|layoutDirection|fontScale"
18
android:excludeFromRecents="true"
19
android:exported="false"
20
android:hardwareAccelerated="true"
21
android:theme="@android:style/Theme.Translucent">
22
<meta-data
23
android:name="hwc-theme"
24
android:value="androidhwext:style/Theme.Emui.Translucent"/>
25
</activity>
26
27
<!-- 应用自升级接口所需要使用的页面-->
28
<activity
29
android:name="com.huawei.updatesdk.service.otaupdate.AppUpdateActivity"
30
android:configChanges="orientation|screenSize"
31
android:exported="false"
32
android:theme="@style/upsdkDlDialog">
33
<meta-data
34
android:name="hwc-theme"
35
android:value="androidhwext:style/Theme.Emui.Translucent.NoTitleBar"/>
36
</activity>
37
38
<!-- 应用自升级接口所需要使用的页面-->
39
<activity
40
android:name="com.huawei.updatesdk.support.pm.PackageInstallerActivity"
41
android:configChanges="orientation|keyboardHidden|screenSize"
42
android:exported="false"
43
android:theme="@style/upsdkDlDialog">
44
<meta-data
45
android:name="hwc-theme"
46
android:value="androidhwext:style/Theme.Emui.Translucent"/>
47
</activity>
48
49
<!-- =============================== 注册Revicer =============================== -->
50
<!-- 接收Push消息广播,此receiver需要开发者自己创建并继承PushReceiver类-->
51
<receiver android:name=".HuaweiPushRevicer">
52
<intent-filter>
53
<!-- 必须,用于接收token-->
54
<action android:name="com.huawei.android.push.intent.REGISTRATION"/>
55
<!-- 必须,用于接收消息-->
56
<action android:name="com.huawei.android.push.intent.RECEIVE"/>
57
<!-- 可选,用于点击通知栏或通知栏上的按钮后触发onEvent回调-->
58
<action android:name="com.huawei.android.push.intent.CLICK"/>
59
<!-- 可选,查看push通道是否连接,不查看则不需要 -->
60
<action android:name="com.huawei.intent.action.PUSH_STATE"/>
61
</intent-filter>
62
</receiver>
63
64
<!-- 接收通道发来的通知栏消息 -->
65
<receiver android:name="com.huawei.hms.support.api.push.PushEventReceiver">
66
<intent-filter>
67
<action android:name="com.huawei.intent.action.PUSH"/>
68
</intent-filter>
69
</receiver>
70
71
<!-- =============================== 注册Provider =============================== -->
72
<!-- 用于HMS-SDK引导升级HMS,提供给系统安装器读取升级文件,这边 要替换上您应用的包名-->
73
<provider
74
android:name="com.huawei.hms.update.provider.UpdateProvider"
75
android:authorities="com.bqt.push.hms.update.provider"
76
android:exported="false"
77
android:grantUriPermissions="true"/>
78
79
<!-- 用于应用自升级,这边 要替换上您应用的包名-->
80
<provider
81
android:name="com.huawei.updatesdk.fileprovider.UpdateSdkFileProvider"
82
android:authorities="com.bqt.push.updateSdk.fileProvider"
83
android:exported="false"
84
android:grantUriPermissions="true">
85
</provider>
86
87
<!-- =============================== 注册Service =============================== -->
88
<!-- 应用下载服务,用于应用自升级-->
89
<service
90
android:name="com.huawei.updatesdk.service.deamon.download.DownloadService"
91
android:exported="false"/>
2018-4-19