Multi Device Push Notifications Approach


We trying to implement multiple device push notifications in our Android and iOS apps. It seems straight forward for iOS. Once dashboard option is enabled, we are always delivered the push notifications no matter in which state the application is. It gives the app the power to control when to show particular notification and when not.
But when it comes to Android, the required implementation, seems pretty rigid. It’s required to not have Firebase notification service in app code, implement SendBirdPushHandler and every notification will be filtered through this handler. This handler won’t dispatch SendBird notifications when app is running in foreground. Is it possible to have an iOS like simpler implementation where we just need to enable the dashboard option and it starts working. The existing approach doesn’t seem scalable as it is binding push notifications handling tightly with SendBird. Also any other notification, which have no link with SendBird, will also be coming through SendBird handler which doesn’t seem very nice to me.

Unfortunately, as Android can be installed on many devices from different companies, it requires extra work and configuration… Sendbird covers the process for the 2 biggest providers: Google and Huawei.
Of course, a foreground-background service can be implemented as well if needed.

1 Like

@Asem If you need to you can handle push notifications yourself instead of Sendbird doing it.

You should register FirebaseinstanceIdService & FirebaseMessagingService to your AndroidManifest.xml.

        <action android:name=""/>
        <action android:name="" />

Once you do this, register the user’s push token to Sendbird via SendBird.registerPushTokenForCurrentUser .

You should then handle received push notification in FirebaseMessagingService.onMessageReceived .

You should turn on always on push in your Sendbird Dashboard (Send to devices both offline and online). The downside for this is, that if the app is in the foreground, the user will receive both web socket events & push notification for the same message received event.

Thanks for the response @walter.rodriguez and @Jason
@Jason’s response is exactly what I’m looking for. I already have this implementation of SendBirdFirebaseMessagingService and SendBird.registerPushTokenForCurrentUser which is like a standard approach for push notifications handling in Android. But the problem is that this is not working for multi-device push notifications, meaning I’m only getting push when all devices are offline. This is mentioned on dashboard

as well that additional implementation is required for multi device support.

@walter.rodriguez @Jason I’m looking forward to your response.

@Asem is your code and logic already embedded in your application or there’s any test project you are working with you can share? Thanks.

@walter.rodriguez this push notification implementation has been in my Android app, in production, for quite sometime now.
Earlier we used to have Send to devices when all offline but recently switched the configuration to Send to devices both offline and online.
This is the behaviour after the configuration update;

  • On Android app with additional implementation, I receive push notifications only on an offline device no matter whether same user is online on any other device. Without additional implementation, user will get notifications only when being offline on all devices (seems like configuration change has no effect).

  • On iOS, every app will receive push notification no matter being in online or offline state.

I want to have exactly same behaviour as iOS is depicting.
I’m using SDK v3.0.157.

Thanks for the support.

Thank you @Asem - I will check what could be the problem.