Android 关于集成环信点击行为不唤起落地页问题
{
"async":false,
"targets": [
"cs1"
],
"strategy": 2,
"pushMessage": {
"title": "环信",
"content": "你好,欢迎使用环信推送服务",
"sub_title": "环信",
"ext":{
"test":"skip test"
},
"config": {
"clickAction": {
"action": "com.a.b.shot"
}
}
}
}
不指定,点击回调我们的应用测试正常。可自行重写PushMessageReceiver 验证是否小米sdk 未触发 PushMessageReceiver.onNotificationMessageClicked
指定,小米推送配置指定action,在相应的Activity中可以调用Intent的getSerializableExtra(PushMessageHelper.KEY_MESSAGE)方法得到MiPushMessage对象。
public class MyMipushReceiver extends EMMiMsgReceiver {
@Override
public void onNotificationMessageClicked(Context context, MiPushMessage miPushMessage) {
String extStr = miPushMessage.getContent();
JSONObject extras = new JSONObject(extStr);
if (extras !=null ){
String t = extras.getString("xxxx");
//handle
}
}
}
public class EMMiMsgReceiver extends PushMessageReceiver {
private static final String TAG = "EMMiMsgReceiver";
public void onNotificationMessageClicked(Context context, MiPushMessage message) {
EMLog.i(TAG, "onNotificationMessageClicked is called. " + message.toString());
Intent msgIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
msgIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(msgIntent);
}
}
{
"async":false,
"targets": [
"cs1"
],
"strategy": 2,
"pushMessage": {
"title": "公子小白有点黑",
"content": "你好,欢迎使用环信推送服务",
"sub_title": "环信",
"config": {
"clickAction": {
"action": "com.a.b.shot",
"activity": "com.hyphenate.easeim.section.me.activity.AboutHxActivity"
}
}
}
}
public class MainActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Bundle extras = getIntent().getExtras();
if (extras != null) {
String t = extras.getString("test1");
String f = extras.getString("test2");
//TODO
}
}
}