信鸽推送集成华为渠道通知补充适用于小米魅族oppovivo

信鸽推送集成华为渠道通知干货
如何设置消息点击事件

TPNS 推荐使用 Intent 方式进行跳转(注:SDK 点击消息默认支持点击事件,触发后打开主界面,如果在 onNotifactionClickedResult 设置跳转操作会与管理台/API中指定的自定义跳转冲突,导致自定义的跳转失效)。
使用 Intent 方式跳转指引:
在客户端 App 的 manifest 上,配置需要跳转的页面:

如要跳转 AboutActivity 指定页面,示例代码如下:

<activity
android:name="com.qq.xg.AboutActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="xgscheme"
android:host="com.xg.push"
android:path="/notify_detail" />
</intent-filter>
</activity>```


若使用服务端 SDK ,设置 Intent 进行跳转,可设置 Intent 为(以 Java SDK 为例):

action.setIntent("xgscheme://com.xg.push/notify_detail");

若需要带上 param1 和 param2 等参数,您可以做如下设置:

action.setIntent("xgscheme://com.xg.push/notify_detail?param1=aa&param2=bb");

在您跳转指定的页面 onCreate 方法里,添加如下代码:

Uri uri = getIntent().getData();
 if (uri != null) {                
String url = uri.toString();
String p1= uri.getQueryParameter("param1");
String p2= uri.getQueryParameter("param2");
}

如果传参包含有特殊字符,如 # 、& 等,可以参考使用如下方式解析:

Uri uri = getIntent().getData();
 if (uri != null) {                
String url = uri.toString();
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.setUnregisteredParameterValueSanitizer(UrlQuerySanitizer.getAllButNulLegal());
sanitizer.parseUrl(url);
String value1 = sanitizer.getValue("key1");
String value2 = sanitizer.getValue("key2");
Log.i("XG" , "value1 = " + value1 + " value2 = " + value2);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章