我的問題對你有以下幾點:我有一個用HTML5編寫的網絡應用程序,它被封裝爲原生Android應用程序以便使用Google推送通知。因爲我的應用程序出於不同的原因正在使用多個通知,所以我希望能夠在每次收到通知時說出要打開的頁面,例如在通知意圖中添加「href」。這可能嗎? 如果我不夠清楚,請讓我知道。 謝謝Android推送通知打開自定義頁面
1
A
回答
0
您可以定義自己的通知消息內容。來自Google的消息構建器支持由通知發件人設置的鍵值對。 見http://developer.android.com/reference/com/google/android/gcm/server/Message.html
例子:
Message message = new Message.Builder()
.addData("link1", "http://mypage1.com")
.addData("link2", "http://mypage2.com")
.build();
0
當您創建的通知,請使用setContentIntent()附加已構建訪問權網頁的意圖:
// assuming <this> is an Activity or other Context
Intent urlIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(yourUrl));
PendingIntent urlPendingIntent = PendingIntent.getActivity(this, 0 urlIntent, 0);
Notification.Builder b = new Notification.Builder(this)
.setSmallIcon(...).setContentTitle(...).setContentText(...) // etc.
.setContentIntent(urlPendingIntent);
NotificationManager noMan
= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
noMan.notify(ID, b.build());
如果你希望有在通知面板中一次多於一個:
- 重新考慮。這是垃圾郵件發佈多個通知。
- 如果必須,您需要爲每個ID分配一個單獨的ID(或單獨的標籤)。
相關問題
- 1. 點擊網頁推送通知時打開自定義網址
- 2. Android:在推送通知頁面後打開瀏覽器外部
- 3. 在推送通知的指定頁面打開應用
- 4. android推送通知打開瀏覽器
- 5. 定義在離子2中點擊推送通知時打開哪個頁面
- 6. 登錄推送通知後打開一個頁面Ionic 2 iOS
- 7. iOS推送通知自定義格式
- 8. 自定義Web推送通知(Google Chrome)
- 9. 推送通知的自定義聲音
- 10. iOS推送通知自定義聲音
- 11. 自定義iOS推送通知音
- 12. 自定義推送通知不顯示
- 13. 通過推送通知打開spicific ViewController
- 14. 打開android通知面板
- 15. 打開推送通知駕駛谷歌
- 16. 在android中使用FCM自定義推送通知
- 17. 推送通知不顯示自定義通知
- 18. Android - 推送通知
- 19. 推送通知 - Android
- 20. 推送通知android
- 21. Android推送通知
- 22. Bluemix Android推送通知無法實現自定義聲音通知
- 23. Ionic2推送通知頁面移動
- 24. 回調推送通知開放的Android
- 25. 如何通過推送通知從AppDelegate打開特定的uitabbarcontroller?
- 26. 發送自定義推送通知給IOS?
- 27. 發送自定義數據的Apple推送通知
- 28. 如何使用OneSignal發送自定義聲音推送通知?
- 29. Android - 解析推送通知崩潰打開
- 30. Android通知,推送時應該打開該活動
我已經在使用這個,所以我可以知道每一個通知是什麼類型的。但是,一旦通知到達,我不知道如何打開我的應用程序的某個webview。我想有一些Intent對象,我仍在搜索。 – Alex
您可以使用url啓動Android瀏覽器,也可以開始自己的包含webview的活動。 請參閱http://stackoverflow.com/questions/2201917/how-can-i-open-a-url-in-androids-web-browser-from-my-application – userM1433372