# Handling Multiple Push Providers

 There's a new version available!

These pages cover version 1 of our SDK, but a newer version is available. In general, we suggest that you update to the latest version to take advantage of new features and fixes.

*   Are you new to our SDKs? [Check out the latest docs.](/integrations/sdk/flutter/getting-started)
*   Otherwise, [learn about updating to the latest version](/integrations/sdk/flutter/whats-new/)

## How to handle multiple push providers[](#how-to-handle-multiple-push-providers)

If you use another push service alongside our SDK (like `FlutterFire`), then that other service takes over push handling by default and prevents your app from receiving rich push notifications from Customer.io.

There are two ways to solve this problem, but we typically recommend [the first option](#cio-process-notification-payloads), because it’s more flexible and lets you process notifications through another service. The second option causes our SDK to take over push handling entirely.

## Option 1 (Recommended): Let Customer.io process notification payloads[](#cio-process-notification-payloads)

You can pass the payloads of other message services to Customer.io whenever a device receives a notification, so our SDK can process it for you. The SDK exposes the `onMessageReceived` and `onBackgroundMessageReceived` methods for this purpose. A `true` value (the default) means that the Customer.io SDK will generate the notification and track associated metrics. A `false` value means that the SDK will only process the notification to track metrics but *will not* generate a notification on the device.

 App in foreground

#### App in foreground[](#App in foreground)

```dart
CustomerIO.messagingPush().onMessageReceived(payload).then((handled) {
  // handled is true if notification was handled by Customer.io SDK; false otherwise
  return handled;
});
```

 App in background

#### App in background[](#App in background)

```dart
CustomerIO.messagingPush().onBackgroundMessageReceived(payload).then((handled) {
  // handled is true if notification was handled by Customer.io SDK; false otherwise
  return handled;
});
```

Imagine that you use FlutterFire (Firebase for Flutter) alongside our SDK. You might use the `onMessageReceived` and `onBackgroundMessageReceived` methods to [handle notifications](https://firebase.google.com/docs/cloud-messaging/flutter/receive#message_handling) like this:

 FlutterFire foreground example

#### FlutterFire foreground example[](#FlutterFire foreground example)

```dart
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
  CustomerIO.messagingPush().onMessageReceived(message.toMap()).then((handled) {
    // handled is true if notification was handled by Customer.io SDK; false otherwise
    return handled;
  });
});
```

 FlutterFire background example

#### FlutterFire background example[](#FlutterFire background example)

```dart
// Annotation is required only for Flutter version 3.3.0 or higher (to prevent removal during tree shaking in release mode)
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp();
  CustomerIO.messagingPush().onBackgroundMessageReceived(message.toMap()).then((handled) {
    // handled is true if notification was handled by Customer.io SDK; false otherwise
    return handled;
  });
}

void main() async {
  // Initialize required SDKs
  FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
  // Run the app
}
```

## Option 2: Register Customer.io Messaging Service[](#register-messaging-service)

If you add another push service along with our SDK, like FlutterFire (Firebase for Flutter), it will take over push notification handling and prevent your app from receiving rich push notifications from Customer.io. To fix this issue, you need to add the following code under the `<application>` tag in the `Manifest.xml` file in your app’s `Android` folder.

```xml
<service
    android:name="io.customer.messagingpush.CustomerIOFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>
```

 This method causes the Customer.io SDK to handle all your push notifications

If you use the code above:

*   Your app will receive all simple and rich push notifications from Customer.io.
*   When your app is in the background, it can receive push notifications with a `notification` payload from other services.
*   Your app **cannot receive** `data`\-only push notifications from another service.