Push Notifications
Marketing Cloud Personalization supports Push Notification campaigns for iOS apps using:
For Personalization Push Notification campaigns to work on your iOS apps, you need to generate APNs certificates and configure Personalization to use those certificates.
- Access your Apple Developer Certificates and click + in the top right corner.
- Select one of the APNs SSL options (Sandbox or Sandbox & Production) and click Continue.
- Select the app and click Continue.
- Follow the instructions to create and complete the Certificate Signing Request.
- Download and install the certificate on your Mac.
- Open Keychain Access from the same Mac.
- Click on My Certificates and find the app's Push Services certificate you just created.
- Check whether the private key is attached to the certificate by clicking the arrow icon to the left of the certificate name.
- Right-click the certificate and click Expose....
- Name the file and select
.p12
as the File Format. - (Optional) Enter a password and click Save.
To upload the APNs certificate and private key .p12
file to Personalization, do the following.
- Log in to the Personalization UI and select the Dataset.
- From the left-hand menu, click Mobile > your app, and then Mobile Push Setup.
- Depending on whether your certificate is Sandbox-only, Production-only, or Sandbox and Production, enter the password for the
.p12
file (if any) in the appropriate fields. - Click Upload p12 File and choose your file to upload.
- Click Save.
If you're using 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.
Additionally, you'll need to provide your APNs certificate to Firebase. For guidance, see Set up a Firebase Cloud Messaging client app on Apple platforms.
If you've provided credentials for both APNs and Firebase, you must pick which one to use when the app is next added to any push notification campaign. Personalization will only send notifications through one channel to prevent duplicating notifications.
To set up your app to use APNs and Firebase Cloud Messaging, do the following.
- Set up the app to use APNs
- Enable the Push Notifications capability and register your app with APNs, as described in Apple's User Notifications documentation.
- Prompt users for desired notification settings using the following methods:
- iOS 10 and newer:
requestAuthorizationWithOptions:completionHandler:
- iOS 8 and 9:
registerUserNotificationSettings:
- iOS 7:
registerForRemoteNotificationTypes:
- iOS 10 and newer:
- If your app uses Firebase Cloud Messaging, refer to Set up a Firebase Cloud Messaging client app on Apple platforms for set up instructions.
- 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
[EVGClientConfigurationBuilder usePushNotifications]
. For example code, refer to theEvergage
class documentation. - Your app should define the callbacks that receive tokens so that Personalization can also start listening. For more information, see
[Evergage(Swizzling) setAPNSToken:]
and[Evergage(Swizzling) setFirebaseToken:]
. - Your app should also define the callbacks that receive notifications. For more information, see
[Evergage(Swizzling) handleNotification:actionIdentifier:]
.
Additional Details
- Personalization can send push notifications to the most recent users only. For more information, see
[Evergage userId]
. - For information on how to ensure campaign click-tracking when you're app receives push notifications while foregrounded, uses
UNNotificationCenterDelegate
, and you decide to render custom UI to the user, see[EVGContext trackClickthrough:actionIdentifier:]
.
- For information on testing your campaigns, see the Testing guide.
- To set up mobile data campaigns for your app, see Mobile Data Campaigns.