Push Notifications
πΉ Tools to use: Leanplum
What are Push Notifications?β
Push notifications are alerts or messages that pop up on a player's device, regardless of whether or not the user is actively playing your game. Depending on the device, push notifications can appear on the device's top notification bar and/or home screen.
All mobile devices allow users to turn off notifications, so some of your players will not receive your push notifications. We recommend using multiple messaging channels to ensure you reach all of your players, including in-app messaging, an app inbox, and/or interstitials.
Games published by Big Fish use Leanplum to send messages from the server to a user's device.
Setting up Push Notificationsβ
Sending push notifications with Leanplum requires additional setup. For detailed instructions, see Set up push notifications βοΈ in Leanplum's documentation.
Additional Steps for Androidβ
Add the Firebase Cloud Messaging (FCM) Server Key
Leanplum uses the Firebase Cloud Messaging service to deliver push notifications on Android devices. Because of this, add the FCM Server key to Leanplum's App Settings:
- Retrieve and copy your FCM Server Key.
- In the Firebase console, click the gear icon next to Overview.
- Go to Project Settings.
- In your project's settings, go to the Cloud Messaging tab. In this section, you will find your Server key, which is your FCM Server Key.
- In the Leanplum Dashboard, go to your App Settings.
- Click on Keys & Settings.
- In the left pane, open the Push Notifications tab.
- Paste the FCM key from step 1 into the Google API key field.
Create Notification Channels
You must define at least one default notification channel before you can start sending push notifications to your players through Leanplum. Use the addAndroidNotificationChannel
and deleteAndroidNotificationChannel
methods of the Leanplum API to add the notification channel(s) you would like to be accessible in the Leanplum dashboard.
For more information, see Leanplum's documentation:
Customize the title and message
By default, Android automatically uses your app's name as the title of push notifications. In addition, the contents of the message is empty. To modify the title and message of your push notification:
- In the Leanplum dashboard, open the Advanced Options for your push notification.
- Under Data, add a new field called "title". Enter the title of your notification.
- Add a field called "message". Enter the message contents of your notification.
The above steps will change the title for a single push notification. To apply this to all push notifications, implement a push customizer βοΈ.
For more information, see Customize Android push notifications βοΈ in Leanplum's documentation.
Additional Steps for iOSβ
Upload certificates
Leanplum uses the Apple Push Notification service (APNs) to deliver push notifications on iOS devices. To complete setup, you must upload your iOS certificates to Leanplum:
- Log in to your Apple Developer Portal provisioning profile.
- In the Identifiers > App IDs section, select your app.
- Click Edit, and enable Push Notifications.
- Click Create Certificate for each of the Development and Production certificates and follow the onscreen instructions. Do not reuse existing certificates
- Download the new certificate files.
- In the Leanplum Dashboard, go to your App Settings.
- Click on Keys & Settings.
- In the left pane, open the Push Notifications tab.
- Upload your .p12 certificates.
Enable iOS project for push notifications (Unity only)
You need to enable your iOS project for push notifications. Add the Push Notifications Capability to the exported iOS project from Unity, either manually from Xcode or through a post-processor build script from Unity.
Register for remote notifications
APNs must know the address of a userβs device before it can send notifications to that device. When you register your app with APNs, you will receive a globally unique device token, which is essentially the address of your app on the current device.
- Unity iOS
- Native iOS
Use the Leanplum.RegisterForIOSRemoteNotifications()
method to register your device through the iOS framework. This method should be called after Leanplum starts (Leanplum.start()
) and asks the user to allow remote notifications directly from Unity.
// Registers the device through the iOS remote push framework
Leanplum.RegisterForIOSRemoteNotifications();
Use UIApplication.registerForRemoteNotifications()
to register your device and use push notification. This method must be used inside of your app delegate's applicationDidFinishLaunching
method.
For more information, see Configure your app for push notifications βοΈ in Leanplum's documentation.
For more information, see:
- Registering your app with APNs βοΈ
- Unity iOS push setup βοΈ
- iOS push notifications βοΈ
Set up rich push notifications (optional)
Before sending any push notifications with images or items apart from text, follow the instructions on Configuring your app for rich push βοΈ in Leanplum's documentation to complete setup.
Creating a Push Notificationβ
Follow these steps to create a new push notification:
- In the Leanplum dashboard, create a new Campaign.
- Select the Campaign Type.
- For Single Message campaigns, select Push Notification from the left menu, and name your campaign. Click Create Campaign.
- For Multi-Message campaigns, enter a name for your campaign, then click Create Campaign. Open the new campaign and select the Actions tab. Click Add Action then select Push Notification. Confirm your select by clicking the Add Action button.
Editing a Push Notificationβ
To edit any push notifications, go to the Messages section of the Leanplum dashboard and select the message you wish to edit.
Messageβ
Use the Message field to define the content of your push notification.
Title and/or Subtitleβ
The process to modify the title and/or subtitle of your message differs based on the platform you are using:
- Android
- iOS
- In the Leanplum dashboard, open the Advanced Options for your push notification.
- Under Data, add a new field called "title". Enter the title of your notification.
- In the Leanplum dashboard, edit your push notification.
- Under iOS options, locate the "Title" and/or "Subtitle" fields.
- Enter the title(s) of your notification.
Open Actionβ
An open action is a function that is performed immediately after a user opens your push notification. Be default, the open action will launch your game. You can change this to any of the following options:
- Open URL: Opens the URL you enter.
- Deep Link: Opens a specific location in your app.
- Offer Wall: Opens the Offer Wall in your app.
- Chain to New/Existing message: Triggers the delivery of another Leanplum message.
- Request App Rating: Requests the user to rate the app.
Gifting Items with Push Notificationsβ
While push notifications typically include text and a call-to-action, you can also gift items using push notifications.
To gift with Leanplum, your project will need to implement a custom action to support gifting. The process of creating a custom action won't be covered, but the steps below will guide you on how to attach the custom action to the built-in messaging capabilities of Leanplum.
For creating your templates and custom actions, begin with these Leanplum guides:
- In-App Messaging βοΈ
- Customizing In-App Messaging βοΈ
Setting Up Gifts using Multi-Message Campaignsβ
Follow the instructions below to create a Multi-Message Campaign with the necessary actions to gift:
- Navigate to your Campaigns and create a new Multi-Message Campaign.
- Select your Audience.
- Select the Delivery Method.
- Add the Push Notification action.
- Fill in the Push notification data as needed.
- Add another action using Opened Action or the + (plus) symbol.
- Add an In-App Message such as an Image Interstitial.
- Update the Sub-Delivery to be Immediate and Deliver when Opened.
- Add a new Button to the push notification. This is needed to interact with the gift.
- Add your custom action as an Open Action and fill in the details.
- Update the Sub-Delivery to Immediate.
You will now have a Multi-Message Campaign that is configured to allow a gift to be claimed by the user.
Setting Up Gifts using Messagesβ
Follow the instructions below to set up a gift push notification message with your custom action:
- Navigate to the Messages board within the Campaign dashboard.
- Click Create Message.
- Fill in the push notification data as needed.
- Add your custom action as an Open Action and fill in the details.
- Click Finish to complete the push notification message.
A new push notification is now created with the associated gift.
Setting Up Gifts using Messages and Chainingβ
Follow the instructions below to set up a gift push notification message that contains chaining.
- Navigate to the Messages board within the Campaign dashboard.
- Click Create Message.
- Select In-App.
- Select Image Interstitial or your custom interstitial template.
- Configure the new interstitial with your custom action Action and fill in the details.
- Click Finish.
- Click Create Message to set up another message.
- Select Push Notification and fill in the details.
- Select Chain to Existing Message for its Open Action and select the message created in Step 2.
You will now have a push notification with the gifting action that will chain to a follow-up push notification.
Testing Gifts using Push Notificationsβ
Manual Delivery of Push Notifications
If you are doing a test and would like to use a Manual Delivery method, ensure that you set the Attribution window to 0. This allows you to send the same campaign again without waiting for the Attribution window to end.
Campaigns can be sent using the startCampaign
REST API. For more information on how to do this, follow the Leanplum Manual Delivery βοΈ guide.
Testing a Campaign and Making Changes
The behavior of getting a campaign to fire is inconsistent. Forcing a restart helps with this issue, and we recommend that you always force a restart after editing a campaign.