-
Notifications
You must be signed in to change notification settings - Fork 12
How to integrate the Infobip Mobile Messaging SDK with another push notifications provider
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.
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.
Other push notification providers might automatically update
AndroidManifest.xmlwhen running commands such as:cordova prepare, cordova build, ...
so they can register their customFirebaseMessagingServicefor acom.google.firebase.MESSAGING_EVENTaction. To prevent this behavior a customafter_preparehook can be written to remove thecom.google.firebase.MESSAGING_EVENTaction from the other push notification provider's service.Here is an example hook, which can be placed in the
hooksdirectory (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"/>
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.
If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
GeofencingDEPRECATED- Privacy settings
- In-app chat
- Migration guides
- Migration guide to version 7.9.x
- Migration guide to version 7.x.x
- Migration guide to version 6.2.x
- Migration guide to version 6.1.x
- Migration guide to version 6.x.x
- Migration guide to version 1.x.x
- Migration guide to version 2.2.x
- Migration guide to version 3.x.x
- Migration guide to version 4.x.x
- Migration guide to version 4.1.x
- Troubleshooting
- JSON Web Token (JWT) structure and generation example
- Trusted Domains Security