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:
...
For the FCM key you’ll need to log into your firebase console > gear icon > project settings > cloud messaging and grab your Cloud Messaging API (Legacy) Server key. Note - you’ll need to make sure this is enabled for your account.
...
If you need to enable this, you can do so by following these steps:
Step 1 Open Firebase console
In the Firebase console, go to Project settings > Cloud Messaging and select Manage API in Google Cloud Console to open Google Cloud Console.
...
To enable the legacy Cloud Messaging API, take the following steps.
Step 1 Open Firebase console
In the Firebase console, go to Project settings > Cloud Messaging and select Manage API in Google Cloud Console to open Google Cloud Console.
To view the image in full screen, click on the
...
Step 2 Go to API Library
Go to API Library using the back button as shown below.
...
Step 3 Find Cloud Messaging API
In the search bar, type "cloud messaging."
...
In the search results, select Cloud Messaging as shown below.
...
Step 4 Enable Cloud Messaging API
Click Enable to start using the Cloud Messaging API.
...
Step 5 Check that the legacy API has been enabled
If you go back to your Firebase console, the Cloud Messaging API should be enabled with a newly generated server key.
...
Finally add your Server key here in UserWise. Note - this information is not stored with UW for security purposes and will be sent / stored in Amazon SNS.:
...
(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:
...
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:
Code Block | ||
---|---|---|
| ||
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); }); |
...