# Multi Device Push Notifications Approach

**URL:** <https://community.sendbird.com/t/multi-device-push-notifications-approach/1789>\
**Category:** Android\
**Tags:** chatsdk\
**Created:** [March 2, 2021, 1:50pm UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789 "2021-03-02T13:50:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asem](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/asem/32/1000_2.png) [@Asem](https://community.sendbird.com/u/Asem)\
**Post date:** [March 2, 2021, 1:50pm UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/1 "2021-03-02T13:50:49Z")

</div>

Hello,

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](https://sendbird.com/docs/chat/v3/android/guides/push-notifications-multi-device-support), 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.

---

<div class="post-metadata">

**Author:** ![walter.rodriguez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/walter.rodriguez/32/546_2.png) [@walter.rodriguez](https://community.sendbird.com/u/walter.rodriguez)\
**Post date:** [March 2, 2021, 2:50pm UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/2 "2021-03-02T14:50:15Z")

</div>

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](https://developer.android.com/guide/background) can be implemented as well if needed.

---

<div class="post-metadata">

**Author:** ![Jason](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/jason/32/488_2.png) [@Jason](https://community.sendbird.com/u/Jason)\
**Post date:** [March 2, 2021, 8:31pm UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/3 "2021-03-02T20:31:26Z")

</div>

@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.

```
<service
    android:exported="false"
    android:name=".SendBirdFirebaseInstanceIDService">
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
    </intent-filter>
</service>
<service
    android:name=".SendBirdFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

```

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.

---

<div class="post-metadata">

**Author:** ![Asem](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/asem/32/1000_2.png) [@Asem](https://community.sendbird.com/u/Asem)\
**Post date:** [March 3, 2021, 3:38am UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/4 "2021-03-03T03:38:04Z")

</div>

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

 ![Screenshot 2021-03-03 at 8.26.48 AM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/0/012ffcf8fd7d6fba44cf82c471700fb3c7083a67.png) as well that [additional implementation](https://sendbird.com/docs/chat/v3/android/guides/push-notifications-multi-device-support) is required for multi device support.

---

<div class="post-metadata">

**Author:** ![Asem](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/asem/32/1000_2.png) [@Asem](https://community.sendbird.com/u/Asem)\
**Post date:** [March 4, 2021, 8:01am UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/5 "2021-03-04T08:01:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![walter.rodriguez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/walter.rodriguez/32/546_2.png) [@walter.rodriguez](https://community.sendbird.com/u/walter.rodriguez)\
**Post date:** [March 4, 2021, 12:40pm UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/6 "2021-03-04T12:40:52Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Asem](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/asem/32/1000_2.png) [@Asem](https://community.sendbird.com/u/Asem)\
**Post date:** [March 4, 2021, 1:34pm UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/7 "2021-03-04T13:34:37Z")

</div>

@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](https://sendbird.com/docs/chat/v3/android/guides/push-notifications-multi-device-support), 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.

---

<div class="post-metadata">

**Author:** ![walter.rodriguez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/walter.rodriguez/32/546_2.png) [@walter.rodriguez](https://community.sendbird.com/u/walter.rodriguez)\
**Post date:** [March 4, 2021, 2:44pm UTC](https://community.sendbird.com/t/multi-device-push-notifications-approach/1789/8 "2021-03-04T14:44:15Z")

</div>

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