OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
105 stars 50 forks source link

OneSignal+Firebase = doubled notifications #140

Closed VitaliLiashchuk closed 5 years ago

VitaliLiashchuk commented 5 years ago

Hi, Previously we used firebase and we used it to send push messages. We have a service which handles firebase event ("com.google.firebase.MESSAGING_EVENT" ) and shows notification messages.

Description: We decided to try OneSignal sdk. It seems that the OneSignal shows push notification then our service handles firebase messaging event and shows the notification once again.

Is there possibility in sdk to handle messages from OneSignal and from Firebase separately? Or it's a bug and should be fixed in sdk?

Environment OneSignal SDK version 3.3.0-beta - (package from NuGet)

jkasten2 commented 5 years ago

@VitaliLiashchuk The native Android Java library com.google.firebase:firebase-messaging won't display a notification sent by OneSignal, since it checks the FCM payload format before processing it. A 2nd notification must being displayed from another library in the app, could you list the exact Firebase library you are using? And if you are using any other notification libraries list those here too

VitaliLiashchuk commented 5 years ago

@jkasten2 I'am using Xamarin.Firebase.Messaging from NuGet. Nothing special just a regular library.

I found same problem here https://stackoverflow.com/questions/39385133/how-to-handle-firebase-cloud-messaging-sdk-and-onesignal-sdk-in-a-same-project

Guys in the link above propose to detect OneSignal push message by "custom key". For me it also works. But can you guarantee that this key always will be sent from OneSignal? Can I be sure that it won't be broken in the future?

jkasten2 commented 5 years ago

@VitaliLiashchuk I see, so you have onMessageReceived setup in your own class and need to keep using it to receive notifications from another service?

If yes, you can check for "custom" key to know if the message is from OneSignal, and use that to omit processing in your onMessageReceived method. We won't change this format so you can reliability use this check

rgomezp commented 5 years ago

Closing due to no response