我是靠谱客的博主 追寻小鸽子,这篇文章主要介绍极光推送能收到通知却收不到自定义消息,现在分享给大家,希望可以做个参考。

public class MyJPushReceiver extends BroadcastReceiver {
private static String TAG = “pushreceiver”;
public MyJPushReceiver() {
}

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@Override public void onReceive(Context context, Intent intent) { // TODO: This method is called when the BroadcastReceiver is receiving // an Intent broadcast. Bundle bundle = intent.getExtras(); Log.d(TAG, "onReceive - " + intent.getAction()); if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) { } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent .getAction())) { // 自定义消息不会展示在通知栏,完全要开发者写代码去处理 String content = bundle.getString(JPushInterface.EXTRA_MESSAGE); String extra = bundle.getString(JPushInterface.EXTRA_EXTRA); System.out.println("收到了自定义消息--------->:"+ content); System.out.println("收到了自定义消息@@消息extra是:"+ extra); //**************解析推送过来的json数据并存放到集合中 begin****************** Map<String, Object> map = new HashMap<String, Object>(); JSONObject jsonObject; try { jsonObject = new JSONObject(extra); String type = jsonObject.getString("type"); map.put("type", type); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } map.put("content", content); //获取接收到推送时的系统时间 Calendar rightNow = Calendar.getInstance(); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); String date = fmt.format(rightNow.getTime()); map.put("date", date);

// MyApp.data.add(map);
//****解析推送过来的json数据并存放到集合中 end******************
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent
.getAction())) {
System.out.println(“收到了通知”);
// 在这里可以做些统计,或者做些其他工作
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent
.getAction())) {
System.out.println(“用户点击打开了通知”);
// 在这里可以自己写代码去定义用户点击后的行为
Intent i = new Intent(context, MainActivity.class); // 自定义打开的界面
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
} else {
Log.d(TAG, “Unhandled intent - ” + intent.getAction());
}
}
// throw new UnsupportedOperationException(“Not yet implemented”);
}

复制代码
1
2
配置文件


复制代码
1

最后

以上就是追寻小鸽子最近收集整理的关于极光推送能收到通知却收不到自定义消息的全部内容,更多相关极光推送能收到通知却收不到自定义消息内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部