//华为推送
implementation 'com.huawei.android.hms:push:2.6.3.301'
解决方法:
创建一个HWPushTranslateActivity
android:launchMode="singleTask">
android:host="com.lanlyc.worksite"
android:path="/notify_detail"
android:scheme="customscheme"/>
Intent intent = new Intent();
intent.setClass(BeginActivity2.this, HWPushTranslateActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("cType", "cType");
intent.putExtra("pid", "pid");
intent.putExtra("projectIP", "projectIP");
intent.putExtra("messageType", "messageType");
intent.putExtra("html_ip", "html_ip");
intent.putExtra("mobile", "mobile");
intent.putExtra("url", "url");
String intentUri = intent.toUri(Intent.URI_INTENT_SCHEME);
LogUtils.d(TAG, "intentUri=" + intentUri);
startActivity(intent);
打印结果:
intentUri=intent:#Intent;launchFlags=0x10000000;component=com.lanlyc.worksite/.receiver.huawei.HWPushTranslateActivity;S.mobile=mobile;S.projectIP=projectIP;S.messageType=messageType;S.pid=pid;S.url=url;S.cType=cType;S.html_ip=html_ip;end
将intent:后的数据交给后端,加入
"action": {
"type": 1,
"param": {
"intent": "#Intent;launchFlags=0x10000000;component=com.lanlyc.worksite/.receiver.huawei.HWPushTranslateActivity;S.mobile=mobile;S.projectIP=projectIP;S.messageType=messageType;S.pid=pid;S.url=url;S.cType=cType;S.html_ip=html_ip;end"
}
}
后端的数据结构
{
"hps": {
"msg": {
"type": 3,
"body": {
"content": "Push message content",
"title": "Push message content"
},
"action": {
"type": 1,
"param": {
"intent": "#Intent;launchFlags=0x10000000;component=com.lanlyc.worksite/.receiver.huawei.HWPushTranslateActivity;S.mobile=mobile;S.projectIP=projectIP;S.messageType=messageType;S.pid=pid;S.url=url;S.cType=cType;S.html_ip=html_ip;end"
}
}
},
"ext": {
"biTag": "Trump",
"customize": [
{
"season": "Spring"
},
{
"weather": "raining"
},
{
"key": {
"messageType": "4",
"cType": "1",
"html_ip": "http://cloud.lanlyc.cn:8080/",
"mobile": "15989469069",
"projectIP": "http://60.205.177.21/lanlyc_gongdi/",
"pid": "640"
}
}
]
}
}
}