我剛剛開始使用Android開發,並在運行嚮導後設法讓Firebase消息傳遞工作。我能夠在運行Nougat的Nexus 5X上收到背景通知。但隨後我的5X升級到奧利奧,並且Firebase通知從此不起作用。我聽說過後臺執行的限制,但由於我剛剛開始,我不知道我必須做些什麼才能讓它再次運行。有沒有關於此的寫作?我從頭開始嘗試一個新項目,希望向導已經更新,但沒有變化。我正在使用應用程序廣播消息和主題訂閱消息,沒有使用設備令牌。Firebase雲消息停止升級到Oreo
回答
請使用最新版本的FCM sdk。
FCM sdk在4月份推出了對Android O的支持,如果您使用的是舊版本,您的應用將無法在Android O中收到消息並可能崩潰。
請參閱最新版本在這裏:https://firebase.google.com/support/release-notes/android
PS:火力SDK已被移到谷歌Maven倉庫。
一定要看看這裏的最新指示: https://firebase.google.com/docs/android/setup#manually_add_firebase
我的Firebase依賴線是: compile'com.google.firebase:firebase-messaging:10.0.1 SDK經理說我完全是最新版本,Android Studio說我在最新版本。如果有更新版本的任何東西,我不知道我該如何找出它。 –
當前版本爲11.4.2,每兩週發佈次要版本 –
因此,Firebase助手嚮導尚未更新以獲取新版本? –
當你定位到Android 8.0(API等級26),你必須實現一個或多個通知信道顯示通知給用戶。如果您不瞄準Android 8.0(API級別26),但您的應用在運行Android 8.0(API級別26)的設備上使用,則您的應用的行爲與在運行Android 7.1(API級別25)或更低級別的設備上的行爲相同。
如果你改變你的目標版本爲安卓8.0(API等級26),你必須做到以下幾點變化
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
String id = "id_product";//This will be enter when creating Builder
// The user-visible name of the channel.
CharSequence name = "Product";
// The user-visible description of the channel.
String description = "Notifications regarding our products";
int importance = NotificationManager.IMPORTANCE_MAX;
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
// Configure the notification channel.
mChannel.setDescription(description);
mChannel.enableLights(true);
// Sets the notification light color for notifications posted to this
// channel, if the device supports this feature.
mChannel.setLightColor(Color.RED);
notificationManager.createNotificationChannel(mChannel);
}
更改您的生成器構造
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(applicationContext, **ID you have put in the Notification Channel**)
最後,你可以創建通知來自Builder
notificationManager.notify("0", notificationBuilder.build())
參考文獻:https://developer.android.com/guide/topics/ui/notifiers/notifications.html#ManageChannels
- 1. Firebase上游雲消息
- 2. firebase雲消息沒有得到註冊
- 3. 未收到Firebase雲消息通知
- 4. Firebase通知 - Firebase雲消息傳遞
- 5. Firebase雲消息傳遞 - 上游消息收到兩次
- 6. Jstack和Jstat停止升級到JDK6u23
- 7. Matplotlib升級到1.1.0後停止工作
- 8. 關閉htmlpurifier升級消息
- 9. Firebase雲消息傳遞(FCM)不止一行
- 10. firebase雲消息傳遞:setBackgroundMessageHandler未調用
- 11. Xcode 8和Firebase雲消息傳遞
- 12. Firebase雲消息傳遞 - 一組設備
- 13. Firebase雲消息傳遞重複通知
- 14. 如何清除Firebase雲消息通知?
- 15. Firebase雲消息iOS Swift無效
- 16. Android,FireBase雲消息傳遞,(FCM)
- 17. Firebase雲消息傳遞發送click_action
- 18. Firebase雲消息傳遞錯誤
- 19. Firebase通知和雲消息傳遞
- 20. Firebase雲消息最低支持sdk
- 21. 接收器在Oreo停止接收
- 22. 通過Firebase雲消息向Android設備發送消息
- 23. Firebase雲消息傳遞 - 向所有用戶發送消息
- 24. Java Firebase雲消息。發送消息給所有
- 25. Swift Firebase雲消息傳遞 - 在後臺發送上游消息
- 26. 升級後流星停止工作
- 27. Firebase - 問題設置Firebase雲消息傳遞
- 28. 如何將firebase雲消息添加到eclipse中?
- 29. 是否可以手動註冊到Firebase雲消息傳遞?
- 30. 某些設備未收到Firebase雲消息
您是否閱讀過:https://developer.android.com/about/versions/oreo/background.html以及您發送郵件的優先級:https://firebase.google.com/docs/cloud-messaging/概念選項#設置優先級信息 –
我讀過,但很難弄清楚我實際上可能需要做什麼。另外一個遷移點是使用FCM選擇性地喚醒應用程序以接收消息,我認爲這正是我一開始做的事情,所以我不明白爲什麼它不起作用。 –