Skip to content

How to integrate the Infobip Mobile Messaging SDK with another push notifications provider

Ivan Bilobrk edited this page May 14, 2025 · 1 revision

If you plan to integrate your mobile application with multiple push notification providers, or maybe you use FCM/APNS to process push from a native backend and don't want to migrate the entire codebase to use with Infobip (for example there's still some use cases where you want to send notifications directly to Firebase/APNS), then you will need to follow this guide.

Android

For Android, you will need to implement a custom FirebaseMessagingService on the native side of your application. For detailed guidance, please refer to the Infobip Android SDK documentation.

Notice

Other push notification providers might automatically update AndroidManifest.xml when running commands such as: cordova prepare, cordova build, ...
so they can register their custom FirebaseMessagingService for a com.google.firebase.MESSAGING_EVENT action. To prevent this behavior a custom after_prepare hook can be written to remove the com.google.firebase.MESSAGING_EVENT action from the other push notification provider's service.

Here is an example hook, which can be placed in the hooks directory (e.g. hooks/remove-fcm-service.js):

#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { DOMParser } = require('@xmldom/xmldom');
const servicesToRemove = [
    'org.infobip.mobile.messaging.cloud.firebase.MobileMessagingFirebaseService',
    '<SecondPushNotificationProviderFirebaseMessagingServiceName>',
];
module.exports = function (context) {
    const androidManifestPath = path.join(context.opts.projectRoot, 'platforms/android/app/src/main/AndroidManifest.xml');
    if (!fs.existsSync(androidManifestPath)) {
        console.log('AndroidManifest.xml not found. Skipping hook.');
        return;
    }
    const androidManifestContent = fs.readFileSync(androidManifestPath, 'utf-8');
    const parser = new DOMParser();
    const doc = parser.parseFromString(androidManifestContent, 'text/xml');
    const services = doc.getElementsByTagName('service');
    let removedAny = false;
    for (let i = services.length - 1; i >= 0; i--) {
        const service = services[i];
        const serviceName = service.getAttribute('android:name');
        if (servicesToRemove.includes(serviceName)) {
            const parent = service.parentNode;
            parent.removeChild(service);
            removedAny = true;
        }
    }
    if (removedAny) {
        const serializer = require('xmldom').XMLSerializer;
        const updatedAndroidManifestContent = new serializer().serializeToString(doc);
        fs.writeFileSync(androidManifestPath, updatedAndroidManifestContent, 'utf-8');
        console.log('Specified services removed from AndroidManifest.xml');
    } else {
        console.log('No specified services found in AndroidManifest.xml. Skipping removal.');
    }
};

After creating the hook, make sure to register it in config.xml:

<hook type="after_prepare" src="hooks/remove-fcm-service.js"/>

Push Notification Permission Handling

To be able to receive push notifications, you need to ask for push notification permission on Android 13 and above. Infobip Mobile Messaging SDK won't automatically ask for push notification permission on Android 13 and above. If you want to use Infobip Mobile Messaging SDK, instead of other push notification provider, to ask for push notification permission, you can check this guide.

Clone this wiki locally