Mobile

Push messaging

Add Firebase Cloud Messaging integration

Push notifications are messages that pop up on mobile devices. App publishers can send them at any time; even if the recipients aren’t currently engaging with the app or using their devices.

Woosmap Mobile push messaging can be integrated with either Google Cloud Messaging (GCM) or Firebase Cloud Messaging (FCM). Although FCM is the latest push platform for Android, both GCM and FCM are fully supported. The following guide use FCM.

Add Firebase to your project

Follow the instructions for Adding Firebase to Your Android Project. If you follow the manual integration process from these instructions, make sure that you follow both steps for Adding Firebase to your app and Adding the SDK.

Add Firebase Cloud Messaging dependency

Add the dependency for Firebase Cloud Messaging in your module’s build.gradle.

dependencies {
    implementation 'com.google.firebase:firebase-messaging:17.3.0'
}

Use default Firebase Service

To ease the push messaging feature inside your app, Woosmap Mobile SDK implement a default Firebase Service.

Connect Woosmap Mobile to FireBase

Update your AndroidManifest.xml file with the below code to connect Woosmap Mobile’s services to FireBase service.

<service android:name="com.webgeoservices.woosmap_mobile_sdk.WoosmapInstanceIDService">
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
</service>
<service android:name="com.webgeoservices.woosmap_mobile_sdk.WoosmapMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

You can now set an Uri to an Activity of your application (example for the uri: woosmap://notif on the MainActivity) and you’re done.

<activity android:name=".MainActivity">
    ...
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="woosmap"
            android:host="notif" />
    </intent-filter>
</activity>
<meta-data android:name="woosmap_notification_defautl_uri" android:value="woosmap://notif" />

Define notification’s icon

To customize the small icon attached to the notifications, add the icon file in the directory res/drawable and update the meta-data in your AndroidManifest.xml file.

<meta-data
android:name="woosmap.messaging.default_notification_icon"
android:resource="@drawable/your_custom_icon_24dp" />

Implement your own Firebase Service

Please, refer to our Android Simple App hosted on GitHub.