华为推送没有跳转到指定页面


    //华为推送
    implementation 'com.huawei.android.hms:push:2.6.3.301'    

解决方法:
    创建一个HWPushTranslateActivity
    
    
       <activity
            android:name=".receiver.huawei.HWPushTranslateActivity"
            android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.app.action.VIEW"/>

                <category android:name="android.intent.category.DEFAULT"/>

                <data
                    android:host="com.lanlyc.worksite"
                    android:path="/notify_detail"
                    android:scheme="customscheme"/>
            </intent-filter>
        </activity>    
        
        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"
                    }
                }
            ]
        }
    }
}        

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值