cen*_*cen 5 android push-notification firebase firebase-cloud-messaging
notification在 Activity 中检索通知标题和正文(JSON 部分),只能data从 Extras 中的 Bundle 中检索该部分。我的主要活动:
Intent intent = getIntent();
if (intent.getExtras() != null) {
debug("Intent with extras");
Bundle b = getIntent().getExtras();
for (String key : b.keySet()) {
Object value = b.get(key);
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}
Run Code Online (Sandbox Code Playgroud)
日志输出:
带有额外内容的意图 google.sent_time 1487153876625 (java.lang.Long) openUrl http://192.168.29.121:8083/v1/messages/87046D17-6470-427C-A046-2E1C92E21D23/open (java.lang.String) customProperties {" big_icon_url":"link"} (java.lang.String) 来自 814199820217 (java.lang.String) google.message_id 0:1487153876640504%a38586a6a38586a6 (java.lang.String) Collapse_key com.kumuluz.ccm.android.sample (java .lang.String)
如您所见,仅给出了数据部分(openUrl、customProperties...)。
如果我手动处理自定义通知,这不是问题,因为我可以将标题和正文推送到附加内容,然后它们会出现在捆绑包中。但是,当应用程序处于后台时,如何从系统处理的通知中获取标题和正文?
我没有看到任何合适的方法来Intent检索它。
| 归档时间: |
|
| 查看次数: |
1880 次 |
| 最近记录: |