Push Notifications
Marketing Cloud Personalization supports Push Notification campaigns for Android apps using Firebase Cloud Messaging (FCM).
If you'd like to use Personalization to send push notifications to your app via FCM, you'll need to provide an FCM private key JSON file. To obtain your FCM private key JSON file and then add it to Personalization, do the following.
-
Open your Firebase Cloud Messaging console for your app.
-
Navigate to Project Overview > Project settings > Cloud Messaging.
-
Click Manage Service Accounts.
-
Click + CREATE SERVICE ACCOUNT.
The default service account is assigned the Firebase Admin SDK Administrator Service Agent role that provides more access than necessary. To limit access and enhance security, we recommend creating a service account with only the Firebase Cloud Messaging API Admin role.
-
Provide appropriate values for Service account name, Service account ID, and Service account description.
-
Click CREATE AND CONTINUE.
-
Under Select a role, search for and select the Firebase Cloud Messaging API Admin role. This role includes the
cloudmessaging.messages.create
permission, which is the only "write" permission required. -
Click CONTINUE.
-
Optionally, grant users access to this service account.
-
Click DONE.
-
Under the Actions column for the newly-created service account, click Manage keys.
-
Click ADD KEY > Create new key.
-
Select JSON as the Key type and click CREATE. The private key JSON file is now saved to our computer. Ensure that you've stored the files appropriately and click CLOSE.
-
Log in to the Personalization UI and select the Dataset.
-
From the left-hand menu, click Mobile > your app > Mobile Push Setup.
-
Under Firebase Cloud Messaging (FCM), upload your private key JSON file.
-
Click Save.
To set up your app to use Firebase Cloud Messaging, do the following.
- Set up your app to use Firebase Cloud Messaging by following the instructions on Set up a Firebase Cloud Messaging client app on Android.
- To allow the collecting and sending of users' Firebase tokens to Personalization, your app must opt-in to Personalization push notification campaigns. For more information, see
usePushNotifications
. For example code, refer to theEvergage
class documentation. - Your app must call
setFirebaseToken
as described in thesetFirebaseToken
method documentation.
Additional Details
- You can only send push notifications to the most recent user. For more information, see
setUserId
. - Personalization automatically tracks clicks and opens from Firebase notifications under typical circumstances. However, when the app receives push notifications while foregrounded, if you decide to display custom content or launch an Activity with a
launchMode
other thanstandard
, you can ensure accurate campaign click tracking by following the instructions in the method documentation fortrackClickthrough(Intent)
andtrackClickthrough(Map)
.
- For information on testing your campaigns, see the Testing guide.
- To set up mobile data campaigns for your app, see Mobile Data Campaigns.