OneSignal / onesignal-expo-plugin

The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.
Other
144 stars 45 forks source link

[question]: Run OneSignal in parallel with expo-notifications #177

Open dgsunesen opened 1 year ago

dgsunesen commented 1 year ago

How can we help?

So I'm experiencing some issues with OneSignal (onesignal-expo-plugin) and expo-notifications running in parallel. Ever since I installed and enabled OneSignal in my app, all listeners for handling user interactions on push notifications are not working anymore. For instance, a user sents another user a message, we send a push notification (using expo-server-sdk), the recipient taps the notification and is send directly to the chat.

To achieve this, I would do something like Notifications.addNotificationResponseReceivedListener(listener) with expo-notifications. Unfortunately, ever since OneSignal was enabled, this is not working. Stuff like requesting permission is working just as before, only listeners seems to be broken.

On the other hand, if I listen for push notifications send with OneSignal, I'm able to react to those using the below example:

OneSignal.setNotificationOpenedHandler(openedEvent => {
  console.log("OneSignal: notification opened:", openedEvent);
  const { action, notification } = openedEvent;
});

Isn't it possible to have both running at the same time?

OneSignal Expo SDK version

1.3.1

Platform

No response

Relevant log output

No response

Code of Conduct

emawby commented 1 year ago

@dgsunesen Thank you for reporting we will need to investigate the compatibility problem. When you send a notification from OneSignal are you able to receive events on the "Notifications.addNotificationResponseReceivedListener" or just the OneSignal handler?

dgsunesen commented 1 year ago

@emawby Only on the OneSignal handler

It seems the issues is only around listening to notification events, whereas e.g. requesting permission like Notifications.requestPermissionsAsync() (https://docs.expo.dev/versions/latest/sdk/notifications/#requestpermissionsasyncpermissions) is still working.

emawby commented 1 year ago

Interesting ok we will investigate. We use something called swizzling to intercept notification events, but we forward them on so that other handlers still receive them. There could be an issue around this when using expo-notifications.

dgsunesen commented 1 year ago

Any news on this?

Let me know if there is anything else you'd need from me in terms of more information or the like

dgsunesen commented 1 year ago

Would be nice to get an update on this :-)

emawby commented 1 year ago

Hello unfortunately we do not have any news to share yet. Are you seeing this warning when your app is started? https://github.com/expo/expo/blob/168ee43f71f005baa11edf98e518593443e1807a/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L32

dgsunesen commented 1 year ago

Hello unfortunately we do not have any news to share yet. Are you seeing this warning when your app is started? https://github.com/expo/expo/blob/168ee43f71f005baa11edf98e518593443e1807a/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L32

No, I don't see that warning

emawby commented 1 year ago

Ok I noticed this issue in their repo as well. I will continue trying to dig through their implementation to find the conflict.

dgsunesen commented 1 year ago

@emawby So meanwhile I've been looking into customer.io and they seem to have some of the same issues. You can see it here — maybe you can get more insights on the issue from that.

emawby commented 1 year ago

@dgsunesen That is helpful I will see if we can make a similar fix

pratikdhody commented 1 year ago

Any luck @emawby ?

dgsunesen commented 1 year ago

Any breakthrough @emawby ? :)

pratikdhody commented 1 year ago

Any breakthrough @emawby ? :)

FYI @dgsunesen I’m in the process of figuring this out also. For me, it’s only affecting iOS where as Android is working as expected. I’m going to be trying to figure out how to disable the one signal listener as I believe it’s what is causing the issue. Disabling this should allow the expo-notifications one to handle the request. Will report back this week.

dtyrrell commented 1 year ago

Any breakthrough @emawby ? :)

FYI @dgsunesen I’m in the process of figuring this out also. For me, it’s only affecting iOS where as Android is working as expected. I’m going to be trying to figure out how to disable the one signal listener as I believe it’s what is causing the issue. Disabling this should allow the expo-notifications one to handle the request. Will report back this week.

kinda weird, since for me iOS is working as expected and Android is getting duplicate notifications...

and I'm trying to stop expo from handling notifications when the app is in the background..

radoam1 commented 10 months ago

I have the same issue any update or workaround or help with this issue ?

Klyado commented 9 months ago

Hi,

Same issue here. Any information / news about this @emawby ?

Thanks for your help.

ovidb commented 7 months ago

We also have duplicated notifications in Android.

It goes away for Android if you update to the latest version of the SDK and plugin, however, now for us the build for IOS is breaking in EAS.

I'm trying to figure out if this is really a true positive before posting an issue, but the bottom line is that for us, updating to the versions bellow made the duplicated notification go away.

"react-native-onesignal": "^5.0.4",
"onesignal-expo-plugin": "^2.0.2",
JohnGeorgiadis commented 1 month ago

We have the same issue on iOS. "expo-notifications": "~0.28.3", "onesignal-expo-plugin": "^2.0.2", "expo": "^51.0.8",

The Notifications.addNotificationResponseReceivedListener from expo-notifications is not firing in ios when I receive a notification from a 3rd service like sendbird. The notifications are coming to the app and I am able to interact with them.

I was also wondering why we cannot just listen to onesignal notifications from Notifications.addNotificationResponseReceivedListener and we need to implement specific onesignal listener OneSignal.Notifications.addEventListener or why onesignal cannot listen to all the notifications coming to the app not just the ones from onesignal.