Cheetah CES Docs Portal

Navigation
Home
GitHub
Email
Corporate Site


FCM - Firebase Cloud Messaging

« Back to Kits References

The FCM (Firebase Cloud Messaging) kit provides the setup needed for apps to receive push notifications.

Know more about FCM by clicking this link.

To include the FCM kit, open the Gradle Scripts | build.gradle (Module: app) and add the following to the dependencies section:

   implementation 'com.cheetahdigital.android:fcm:<version>'


On this page:

Overview

Push Notifications are messages you can display to the user outside of your application’s normal UI. With the FCM kit, receiving notifications for the app from the server is made easier.

UI Layout of Push Notification

UI Layout of Push Notification

Push notifications can also contain these attachment types:

If notification has an attachment type, it will redirect to the details page of the specified attachment. If notification does not have attachment type, it will open the Messages List.

FCM Implementation

  1. Call the FCMUtils’s initializeFCM method from your MainActivity:
FCMUtils.initializeFCM(MainActivity.this);

If there are no issues with the device properties, the device will be registered as a recipient in the Cheetah Digital Servers.

  1. By default in this kit, once the push notification is clicked it will look for the activity with this intent-filter:
 <intent-filter>
 		<action android:name="${applicationId}.MESSAGES" />
 		<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Add this to the desired Activity, usually it would be the Inbox or if there is no inbox the Main Activity will do.

  1. Different attachments are also supported in the push notifcation. If the push notification includes an attachment type and id, make sure to have the following in your AndroidManifest.xml
<!-- Challenge Details -->
<activity android:name="com.cheetahdigital.challenges.ui.challenges.ChallengeDetailsActivity">
	<intent-filter>
		<action android:name="${applicationId}.CHALLENGE_DETAILS" />
		<category android:name="android.intent.category.DEFAULT" />
	</intent-filter>
</activity>
<!-- Offer Details -->
<activity
            android:name="com.cheetahdigital.offers.ui.details.OfferDetailsActivity"
            android:exported="false"
            android:screenOrientation="portrait">
	<intent-filter>
		<action android:name="${applicationId}.OFFER_DETAILS" />
		<category android:name="android.intent.category.DEFAULT" />
	</intent-filter>
</activity>
<!-- Reward Details -->
<activity
            android:name="com.cheetahdigital.rewards.ui.rewards.detail.RewardDetailsActivity"
            android:screenOrientation="portrait">
	<intent-filter>
		<action android:name="${applicationId}.REWARD_DETAILS" />
		<category android:name="android.intent.category.DEFAULT" />
	</intent-filter>
</activity>
<!-- Newsfeed -->
<activity
            android:name="com.cheetahdigital.newsfeed.ui.list.FeedsListActivity"
            android:parentActivityName="com.cheetahdigital.sdk.MainActivity"
            android:screenOrientation="portrait">
	<intent-filter>
		<action android:name="${applicationId}.FEED_LIST" />
		<category android:name="android.intent.category.DEFAULT" />
	</intent-filter>
</activity>
<!-- Member Details -->
<activity android:name="com.cheetahdigital.members.ui.detail.MemberDetailsActivity">
	<intent-filter>
		<action android:name="${applicationId}.MEMBER_DETAILS" />
		<category android:name="android.intent.category.DEFAULT" />
	</intent-filter>
</activity>

Fully Custom UI

You may edit the notification icon for the push notification by overriding this res/drawable file

R.drawable.small_notif_icon; // for android versions Kitkat and below (4.4.4 and below)
R.drawable.small_notif_icon_white; // for android versions Lollipop and above(5 and above)
R.drawable.large_app_icon; // image on the expanded view


« Back to Kits References