OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
Background push in Android and IOS
I switched to the latest version (3.3.0) and there are fewer features than before. Once pushes worked in the background in IOS, then after new versions they stopped working. Now even in Android it is impossible to receive a push in the background, as it was in setNotificationReceivedHandler. Are you planning to return at least for Android or not to wait for this important feature? Thanks
@VisualMafia Thanks for your question. The setNotificationReceivedHandler was replaced with setNotificationWillShowInForegroundHandler. As the name notes, this will only fire when your app is in the foreground and let's you decide if you want to show notification to the user.
The original setNotificationReceivedHandler from 2.x.x had a number of limitations that does not allow it to fire in all cases in the background so it was removed.
What is the use case for the setNotificationReceivedHandler you have? I would like to know how we can support this.
Thanks for the answer, yes, we use the setNotificationWillShowInForegroundHandler method, but this is not enough. Previously, setNotificationReceivedHandler covered our needs (in Android). Every push is important to us, and if only setNotificationWillShowInForegroundHandler, then all messages are lost when the application is in the background. Can we read all the pushes that have arrived when the application returns from the background?
Can we read all the pushes that have arrived when the application returns from the background?
Thanks for the details, that is good information to have. Do you only need the notifications are currently showing (not interacted with) or all notifications received?
The OneSIgnal native SDK (that this Flutter repo uses) does still include options for these, however it requires you to write native code: https://documentation.onesignal.com/docs/service-extensions
One if the major limitations of setNotificationReceivedHandler in the old SDK is that if the User swiped away your app it would no longer fire. This is due to iOS's limitations, they require you to add a Notification Service Extension to account for this, however it has to be written in Swift or Objective-C.
Thanks for the answer. But, in Android it worked fine before. It is important for us to see the data that came in the push when the application is active or in the background. Now this only works when the app is active.
Thanks for the answer. But, in Android it worked fine before. It is important for us to see the data that came in the push when the application is active or in the background. Now this only works when the app is active.
Exactly, there are some PR's also fixing this but the team is not taking note of this issue.
I read docs for background data notification and add a service file too but I still can’t make any progress
I read docs for background data notification and add a service file too but I still can’t make any progress
Have you found a solution to receive notification while app is in background?
I read docs for background data notification and add a service file too but I still can’t make any progress
Have you found a solution to receive notification while app is in background?
one signal is already capable of sending a notification when the app is in the background but I can’t find anything to trigger any specific function when a notification arrives in-app background state
Any updates?
any update
@mo-ah-dawood
any update
I update my code like this whenever a user using the app and a notification arrives, I trigger the foreground notification function and run the function without showing any notification.
OneSignal.shared.setNotificationWillShowInForegroundHandler((event) {
// Will be called whenever a notification is received in foreground
// Display Notification, pass null param for not displaying the notification when notification TYPE from server changes
final notification = event.notification;
if (notification.additionalData!["type"] == "NOTIFICATION_TEXT") {
event.complete(notification);
} else {
getUpdatedData(context); //Function
event.complete(null);
}
print("this is notification title: ${notification.title}");
print("this is notification body: ${notification.body}");
print(
"this is notification additional data: ${notification.additionalData}");
});
I know how to handle my data in foreground but what about the notifications that comes while the app is in background
I know how to handle my data in foreground but what about the notifications that comes while the app is in background
I'm facing the same problem, I haven't found a way yet to handle notifications that are received in the background... any help?
no, currently I'm loading all my APIs after app resumed from background I know its very heavy for my app but it was my only solution
I am facing the same problem, I am able to receive the notification, but there is no way to handle it while my app is still in background
Anyone who understands native code for this please help, Onesignal team isn't helping here. Also if anyone can understand this fix code https://github.com/OneSignal/OneSignal-Flutter-SDK/pull/464
Has someone succeded to display notifications in background ?
Any workarounds available to receive notifications in the background?
Folks, I'm here looking for a solution to the same problem ... is there a way to handle push notification received when in background? (or should we change and not using One Signal?)
The solution I found was to create an event channel to handle messages in the background
Em sex., 21 de jul. de 2023 às 14:38, Carlos Daniel < @.***> escreveu:
Folks, I'm here looking for a solution to the same problem ... is there a way to handle push notification received when in background? (or should we change and not using One Signal?)
— Reply to this email directly, view it on GitHub https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/557#issuecomment-1646037803, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHL3RC53BJMN7JZN2U2UXSDXRK5CLANCNFSM5WZZJ4TQ . You are receiving this because you commented.Message ID: @.***>
@viniciusoliverrs thanks for letting us know ... although if I'm understanding well, did you create a new package (channel) not public in which you did your own background push notifications handle? If so and possible, could you share some gist or something?
Some solution to this issue? This is a huge limitation to using OneSignal in any projects.
It is indeed ... no workarounds from my side, so far
any update?
The effect of this issue is that if the user sees the notification but chooses to open the app instead (app being in background) we are not informed in the code that there was a notification actually. We loose the notification. And since we use one-signal integrated with MixPanel this is mandatory as custom cohorts are available only between these platforms, not in our backend.
HELP!!!
Hi everyone, has anyone been able to implement push notifications in the background with Onesignal?
Any updates?
Any update?
On 2024-05-20 14:35, Gonn01 wrote:
Any update?
-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you commented.Message ID: @.***>
Links:
[1] https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/557#issuecomment-2120590946 [2] https://github.com/notifications/unsubscribe-auth/BCLZNDLTS3BTEKIG4ZZO733ZDIC45AVCNFSM5WZZJ4T2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJSGA2TSMBZGQ3A I have fixed the issue that I had. Thanks for reaching out.
@femiWiseki - if you managed to fix the issue, can you share with us how? We all need to be able to handle these notifications when the app is in the background. Thank you.