Push Notification
The first thing you’ll want to do when setting up PNs is to go into the UserWise dashboard > Settings > Push Notification Frameworks so you can add your Firebase API Key and APN.
Android Push Notifications: (Updated for FCM v1 API)
To create a new (or update a previous) FCM connection, you must provide UserWise with a valid JSON-formatted service account file. This service account can be managed through GCP’s IAM by creating a service account with limited permissions, or you can use the default service account provided by Firebase.
Getting the credentials
For the purposes of this section we will assume the usage of the default service account. And that you do not already have JSON-formatted service account credential files.
First, we’ll want to navigate to Firebase. Once there choose your application, and navigate to the Project settings for that application (Cogwheel).
Once on the Project settings page, navigate to the Service accounts tab. Click “Generate new private key”
Providing Credentials to UserWise
After either procuring your own service credentials file, or using the steps above, you are now ready to connect UserWise to Firebase Cloud Messaging.
First, you will need to navigate to your app’s push notifications frameworks page. Once there find the section which shows your connection statuses:
Click the pencil icon, which and choose “Manage FCM Connection”. This will open a dialog that will ask for your credentials file:
Drag and drop, or click the drop location and choose your service account credentials file. Once selected, press save. If the credentials file is valid, your status indicator should change colors to blue, indicating a successful connection has been made with FCM:
Apple Push Notifications:
To setup APNs you’ll need to generate a .p8 file in Apple and add that into UserWise to be able to deliver PNs to your players.
To generate a .p8 key file, go to Apple developer account page , then select Keys under Certificates, Identifiers & Profiles
Click the + button to add a new key
In the new key page, type in your key name and check the Apple Push Notification service (APNs) box , then click Continue.
On the next page, you’ll want to note your Key ID and most importantly click the Download button to download your .p8 file. Note - you will not be able to download this file again.
Next you’ll need to grab your team ID on your main page > Membership Details:
Finally grab your APN bundle ID under App Information > General Information:
Add all those into UserWise:
With that, you should have blue status markers indicating everything is setup:
Unity
Back in Unity you’ll want to grab the device token for this player’s device and then register them to UserWise:
DeviceToken = await Firebase.Messaging.FirebaseMessaging.GetTokenAsync();
NotificationPlatform platform = (Application.platform == RuntimePlatform.Android) ?
NotificationPlatform.fcm :
NotificationPlatform.apns;
UserWise.INSTANCE.PushNotificationsModule.RegisterDeviceToken(platform, DeviceToken, (success) =>
{
UnityEngine.Debug.Log("Device token registration succeeded? " + success);
});
Once that’s connected, you’re ready to start sending push notifications! More detailed example can be found here.
Powered by UserWise