0

I was having some difficulties in implementing the notifications for API 26 and above. The notification arrives when app is open but no notifications are received when the app is in background or closed.(I have included notification channels as per the documentation)

Stefan Zobel
  • 3,182
  • 7
  • 28
  • 38
Vinu Polly
  • 61
  • 1
  • 8

2 Answers2

3

Thanks guys, i found the sollution, apparently the minimum verssion of firebase messaging to be used is 11.2.0 while targetting api 26, i was using 10,2.0

Vinu Polly
  • 61
  • 1
  • 8
0

Based on the documentation:

FCM attempts to deliver high priority messages immediately, allowing the FCM service to wake a sleeping device when necessary and to run some limited processing (including very limited network access). High priority messages generally should result in user interaction with your app. If FCM detects a pattern in which they don't, your messages may be de-prioritized

You need to ensure that user is interacting with app otherwise the Notification wont be delivered immediately in doze mode.

Sagar
  • 23,903
  • 4
  • 62
  • 62
  • But in api 25 and below notifications are delivered immediately as i issue it from server using the php code even if the app is not running. So in api 26 and above notifications wont be delivered if the app is in background/not running ? – Vinu Polly May 27 '18 at 07:45
  • if i change the target api to 25 from 26 then it works fine, but in order for the app to be published to play store all apps have to target to api 26 before august 2018 – Vinu Polly May 27 '18 at 07:50
  • @VinuPolly Altough level 26 comes with stricter limitations on background processing, the official documentation doesn't mention special treatment for Notifications. You just need to ensure, proper Notification channel is created and you are running any background service. – Sagar May 27 '18 at 07:56
  • The notification display and delivery depends on OS. Just ensure that you are not breaking the rules. – Sagar May 27 '18 at 07:58
  • the notification channel has been created because its visible inside the Notification setting, the channel name is visible and i can edit the channel preferences. so im guessing the channel creation is proper. – Vinu Polly May 27 '18 at 08:12
  • 05-27 12:42:28.899 1692-3295/? E/NotificationService: No Channel found for pkg=com.example.app, channelId=null, id=0, tag=GCM-Notification:27961960, opPkg=com.example.app, callingUid=10086, userId=0, incomingUserId=0, notificationUid=10086, notification=Notification(channel=null pri=0 contentView=null vibrate=null sound=content://settings/system/notification_sound defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE) ^^^^ Get this above error when i recieve notification in the background in the logcat when i put no filters – Vinu Polly May 27 '18 at 08:40
  • This error happens if you are not creating notification properly. Also ensure you are using latest version of firebase library – Sagar May 27 '18 at 10:15