使用Firebase Cloud Messaging在後臺接收通知時,是否可以使Android設備發生振動?從Syntax Reference我已經看到並測試聲音支持,但沒有振動的信息。或者是否有可能爲此通知提供自定義實現,以便直接設置振動?Firebase Cloud Messaging通知振動
回答
從我所測試的FCM通知消息的格式似乎是相當嚴格的,所以對於自定義通知,該解決方案似乎是:
- 確保該JSON消息的有效載荷發送下游包含
data
參數,但不包含notification
參數(來源:Message JSON Syntax,FCM Message Types) - 從應用程序的
FirebaseMessagingService
創建的覆蓋onMessageReceived(RemoteMessage remoteMessage)
執行情況的通知(Example)
這只是通知**聲音**或還**振動**? – newbieguy
你應該標記自己是一個正確的答案。
在旁註,如果你發送通知和數據有效載荷,可使用
"notification":{
"sound":"default"
}
當應用程序在後臺和設備設置聲音這將播放的聲音,它會玩如果設備設置爲振動,則會發生振動。
但是,就自定義而言,我認爲只有在您想要自定義振動模式時才需要使用數據有效載荷。
array("title"=>"hello","body" =>"hello world",'sound' => 'default')
將它存儲在一個變量中,然後使用此函數 –
function send_notification($ tokens,$ notification) { $ url ='https://fcm.googleapis.com/fcm/send'; $ priority =「high」; $字段=陣列( 'registration_ids'=> $令牌, '通知'=> $通知 ); –
將代碼添加到答案中 – Raviteja
- 1. Firebase Cloud Messaging問題
- 2. PushSharp Google Cloud Messaging單元通知
- 3. Firebase Cloud Messaging not calling FirebaseInstanceId
- 4. Firebase Cloud Messaging - 處理註銷
- 5. Firebase Cloud Messaging AppDelegate錯誤
- 6. 使用Firebase Cloud Messaging顯示大視圖通知
- 7. GeneXus支持Firebase Cloud Messaging作爲推送通知服務?
- 8. Firebase推送通知在後臺振動
- 9. Firebase Cloud Messaging設置但未收到來自Firebase控制檯的推送通知
- 10. Firebase Cloud消息沒有聲音/振動
- 11. Firebase Cloud Messaging不同的密鑰
- 12. Firebase Cloud Messaging設備組泄漏
- 13. 如何使用ionic 3和Firebase Cloud Messaging從通知欄打開特定頁面?
- 14. Firebase Cloud Messaging用令牌替代服務器密鑰以發送通知/消息
- 15. firebase-messaging-sw.js在firebase網絡通知中的用途是什麼?
- 16. Google Cloud Messaging
- 17. Google Cloud Messaging(GCM)
- 18. Android通知振動時間
- 19. 通知不會振動
- 20. 振動推送通知
- 21. 爲什麼在安裝Firebase Cloud Messaging時會自動添加Firebase Analytics SDK?
- 22. Google Cloud Messaging向所有設備發送通知
- 23. 使用Google Cloud Messaging發送廣播通知
- 24. 如何使用Google Cloud Messaging推送通知?
- 25. 使用Google Cloud Messaging錯誤推送通知
- 26. 如何修改Google Cloud Messaging中的通知接收方?
- 27. iOS中的GCM(Google Cloud Messaging)(通知和數據負載)
- 28. Mule ESB Google Cloud Messaging
- 29. Google Cloud Messaging示例
- 30. Google Cloud Messaging Smack Library
我認爲您需要在構建通知時實施。你以前見過這個[post](http://stackoverflow.com/q/18253482/4625829)嗎? –
FCM的事情是,當發送通知並且應用程序位於後臺時,[通知內部構建](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications)。我認爲自定義通知的解決方案是僅提供數據負載,因此[保證我的服務的onMessageReceived()方法將被調用](https://firebase.google.com/docs/cloud-messaging/concept-options #notifications_and_data_messages),然後在方法實現中構建通知 – apidae
另請參閱https://stackoverflow.com/questions/42555899/firebase-push-notifications-vibrate-in-background – Kato