Firebase fire service stopped with upgrade to Oreo

I just started working with Android development and was able to start Firebase messaging after starting the wizard. I managed to get a background alert on my Nexus 5X, working with Nougat. But since then, my 5X has been updated to Oreo and Firebase notifications. I have heard about background execution restrictions, but since I'm just starting out, I don’t know what I really need to do to get it working again. Are there any notes about this? I tried a new project from scratch, hoping that the wizard was updated, but no changes. I used application broadcast messages and subscription message topics, I did not use a device token.

+4
source share
2 answers

Please use the latest version of FCM sdk.

FCM sdk introduced support for Android O in April, if you use an older version, your application will not receive messages in Android O and could potentially crash.

See the latest version here: https://firebase.google.com/support/release-notes/android

PS: Firebase SDK ported to Google Maven repository.
Be sure to check out the latest instructions here: https://firebase.google.com/docs/android/setup#manually_add_firebase

+3
source

Android 8.0 ( API 26), . Android 8.0 ( API 26), Android 8.0 ( API 26), , Android 7.1 (API- 25) .

Android 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);
  }

Builder

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

+4

Source: https://habr.com/ru/post/1687127/


All Articles