Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to handle background notification in android #2190

Open
1 task done
S00raj-hcbs opened this issue Sep 9, 2024 · 2 comments
Open
1 task done

[Bug]: Unable to handle background notification in android #2190

S00raj-hcbs opened this issue Sep 9, 2024 · 2 comments

Comments

@S00raj-hcbs
Copy link

S00raj-hcbs commented Sep 9, 2024

What happened?

i am unable to handle background notification
notificationBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(name)
.setContentText("Incoming " + callType + " Call")
.setSmallIcon(R.drawable.cdoc_logo)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setCategory(NotificationCompat.CATEGORY_CALL)
.addAction(R.drawable.btn_hangup, "Reject Call", cancelCallPendingIntent)
.addAction(R.drawable.btn_accept_call, "Accept Call", receiveCallPendingIntent)
.setAutoCancel(true)
//.setSound(ringUri)
.setFullScreenIntent(callDialogPendingIntent, true);

                        but not come in call service this function.

Steps to reproduce?

- run app
- app go to background.
- send call notification but show only notification not call callservice. and not come in my handler.

What did you expect to happen?

i want to call callservice class when come notification in background. Handle notification in background.

OneSignal Android SDK version

5.1.21

Android version

14

Specific Android models

Samsung galexy a14

Relevant log output

Logs : 2024-09-09 13:30:21.864  4160-4199  OneSignal               com.cybermed.cdoc                    I  [DefaultDispatcher-worker-3] Fire remoteNotificationReceived
2024-09-09 13:30:21.868  4160-4211  OneSignal               com.cybermed.cdoc                    I  [DefaultDispatcher-worker-6] App is in background, show notification
2024-09-09 13:30:21.879  4160-4211  OneSignal               com.cybermed.cdoc                    V  [DefaultDispatcher-worker-6] Cannot use background images in notifications for device on version: 34
2024-09-09 13:30:21.888  4160-4211  NotificationManager     com.cybermed.cdoc                    I  com.cybermed.cdoc: notify(2005943928, null, Notification(channel=fcm_fallback_notification_channel shortcut=null contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x10 color=0x00000000 vis=PUBLIC semFlags=0x0 semPriority=0 semMissedCount=0)) as user
2024-09-09 13:30:21.895  4160-4211  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-6] Saving Notification job: NotificationGenerationJob{jsonPayload={"google.delivered_priority":"high","google.sent_time":1725868821412,"google.ttl":2419200,"google.original_priority":"high","custom":"{\"i\":\"2d882551-7467-4f06-8d3a-99c336defb96\",\"a\":{\"onlinestatus\":\"1\",\"roomnumber\":\"CM_20240909040020_97352bf9-9536-4b5a-a8f5-8242cdb4f60a\"}}","google.product_id":111881503,"pri":"10","from":"197863783491","alert":"Provider CyberMed Test","google.message_id":"0:1725868821426895%e5e98a83f9fd7ecd","google.c.sender.id":"197863783491"}, isRestoring=false, isNotificationToDisplay=true, shownTimeStamp=1725868821, overriddenBodyFromExtender=null, overriddenTitleFromExtender=null, overriddenSound=null, overriddenFlags=null, orgFlags=null, orgSound=null, notification=OSNotification{notificationExtender=null, groupedNotifications=null, androidNotificationId=2005943928, notificationId='2d882551-7467-4f06-8d3a-99c336defb96', templateName='null', templateId='null', title='null', body='Provider CyberMed Test', additionalData={"onlinestatus":"1","roomnumber":"CM_20240909040020_97352bf9-9536-4b5a-a8f5-8242cdb4f60a"}, smallIcon='null', largeIcon='null', bigPicture='null', smallIconAccentColor='null', launchURL='null', sound='null', ledColor='null', lockScreenVisibility=1, groupKey='null', groupMessage='null', actionButtons=null, fromProjectNumber='197863783491', backgroundImageLayout=null, collapseId='null', priority=10, rawPayload='{"google.delivered_priority":"high","google.sent_time":1725868821412,"google.ttl":2419200,"google.original_priority":"high","custom":"{\"i\":\"2d882551-7467-4f06-8d3a-99c336defb96\",\"a\":{\"onlinestatus\":\"1\",\"roomnumber\":\"CM_20240909040020_97352bf9-9536-4b5a-a8f5-8242cdb4f60a\"}}","google.product_id":111881503,"pri":"10","from":"197863783491","alert":"Provider CyberMed Test","google.message_id":"0:1725868821426895%e5e98a83f9fd7ecd","google.c.sender.id":"197863783491"}'}}
2024-09-09 13:30:21.897  4160-4211  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-6] Saving Notification id=2d882551-7467-4f06-8d3a-99c336defb96
2024-09-09 13:30:21.919  4160-4211  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-6] Notification saved values: full_data={"google.delivered_priority":"high","google.sent_time":1725868821412,"google.ttl":2419200,"google.original_priority":"high","custom":"{\"i\":\"2d882551-7467-4f06-8d3a-99c336defb96\",\"a\":{\"onlinestatus\":\"1\",\"roomnumber\":\"CM_20240909040020_97352bf9-9536-4b5a-a8f5-8242cdb4f60a\"}}","google.product_id":111881503,"pri":"10","from":"197863783491","alert":"Provider CyberMed Test","google.message_id":"0:1725868821426895%e5e98a83f9fd7ecd","google.c.sender.id":"197863783491"} notification_id=2d882551-7467-4f06-8d3a-99c336defb96 android_notification_id=2005943928 opened=0 expire_time=1728288021 message=Provider CyberMed Test
2024-09-09 13:30:21.943  4160-4197  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-1] sendReceiveReceipt disabled
2024-09-09 13:30:21.944  4160-4197  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-1] InfluenceManager.onNotificationReceived(notificationId: 2d882551-7467-4f06-8d3a-99c336defb96)
2024-09-09 13:30:21.944  4160-4197  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-1] ChannelTracker.saveLastId(id: 2d882551-7467-4f06-8d3a-99c336defb96): idTag=notification_id
2024-09-09 13:30:21.946  4160-4197  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-1] ChannelTracker.saveLastId: for notification_id saveLastId with lastChannelObjectsReceived: [{"notification_id":"da710be9-b553-4dad-9a4b-996c75f6289b","time":1725631368440},{"notification_id":"d7ab9619-4725-438d-ab3e-8abefcfc7382","time":1725631401268},{"notification_id":"17fe8e82-9087-4fcf-9088-24d4e2307cf0","time":1725631596669},{"notification_id":"32ef2879-4dfb-4538-bdcf-3253ac37783b","time":1725631612348},{"notification_id":"102dfcf0-b3dd-449b-897f-6e444f856008","time":1725865485471},{"notification_id":"8acf4890-5021-4f80-99a8-a0104777b28f","time":1725867421399},{"notification_id":"09c2df5d-4353-46fa-9d60-1dc2079ef0b9","time":1725867446771},{"notification_id":"e5685462-d63c-4c6f-a1d0-02a6b41cc755","time":1725867661325},{"notification_id":"992e5110-a0d2-4779-9d64-8a1839dc0f95","time":1725867859063},{"notification_id":"bb7093c9-56d2-4cb7-a6df-2e133b67274d","time":1725867944141}]
2024-09-09 13:30:21.948  4160-4197  OneSignal               com.cybermed.cdoc                    D  [DefaultDispatcher-worker-1] ChannelTracker.saveLastId: for notification_id with channelObjectToSave: [{"notification_id":"d7ab9619-4725-438d-ab3e-8abefcfc7382","time":1725631401268},{"notification_id":"17fe8e82-9087-4fcf-9088-24d4e2307cf0","time":1725631596669},{"notification_id":"32ef2879-4dfb-4538-bdcf-3253ac37783b","time":1725631612348},{"notification_id":"102dfcf0-b3dd-449b-897f-6e444f856008","time":1725865485471},{"notification_id":"8acf4890-5021-4f80-99a8-a0104777b28f","time":1725867421399},{"notification_id":"09c2df5d-4353-46fa-9d60-1dc2079ef0b9","time":1725867446771},{"notification_id":"e5685462-d63c-4c6f-a1d0-02a6b41cc755","time":1725867661325},{"notification_id":"992e5110-a0d2-4779-9d64-8a1839dc0f95","time":1725867859063},{"notification_id":"bb7093c9-56d2-4cb7-a6df-2e133b67274d","time":1725867944141},{"notification_id":"2d882551-7467-4f06-8d3a-99c336defb96","time":1725868821946}]

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jkasten2
Copy link
Member

jkasten2 commented Sep 9, 2024

@S00raj-hcbs OneSignal.getNotifications().addForegroundLifecycleListener() only fires when your app is in focus. If you want to handle the notification no matter that state of your app you will need to setup the OneSignal Android Notification Service Extension:

@S00raj-hcbs
Copy link
Author

but not come here any data in Service Extension class. logcat show me only onesignal log not show me log which i have put in Service Extension class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants