集成华为推送,华为手机App在活动点开推送重启App并且未进入到推送落地页

问题描述:

1、为了提高推送的到达率,在有极光推送的基础上,App又集成了小米、魅族、华为三家自己的推送服务。

2、华为手机在App在前台时候,点击推送App重启,并且推送没有进入到对应的落地页。(又是你,华为!)

解决问题:

后台发送推送时页面,会有如图内容:

解决步骤:

1、首先在AndroidManifest.xml文件中点击推送跳转的Activity添加如下代码:

  • host内容可以自定义
  • scheme内容可以自定义
<!-- 需要跳转到的页面-->
        <activity
                android:name=".demo.activity.PushDemoActivity"
                android:screenOrientation="portrait">
            <intent-filter>

                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:host="com.myhost.push"
                      android:path="/push_detail"
                      android:scheme="myscheme"/>
            </intent-filter>
        </activity>
2、之后在Activity当中打印出Intent内容,代码如下:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("myscheme://com.myhost.push/push_detail?message=what"));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        String intentUri = intent.toUri(Intent.URI_INTENT_SCHEME);
        Log.e("====","action是:" + intentUri);
得到打印的intentUri的内容大致如下:
intent://com.myhost.push/push_detailmessage=what#Intent;scheme=myscheme;action=android.intent.action.VIEW;launchFlags=0x10000000;end

将这个内容复制到上图【自定义动作】输入框内容。

备注:

【host】、【scheme】内容都可以自定义。


华为推送相关问题:

  • 这里说几点关于华为推送的问题。

1、华为推送的初始化依赖于Activity,所以不能在Application当中初始化。

2、华为推送服务当中的【透传消息】是可能会丢失的,例如:App被杀死后,透传消息有时接收不到,如果重启App,透传消息依然接收不到。所以不推荐使用【透传】实现重要的功能。

猜你喜欢

转载自blog.csdn.net/nsacer/article/details/80346965
今日推荐