Push Notifications For Unity Android

If you wish to use any of the Push Campaign or Push Point features of User Hook, you will need to follow a few additional steps while setting up your app.

First, you will need to create a Google Firebase project and download the google-services.json file. You will not need to install the Firebase SDK as that is already installed using the UserHook.unitypackage.

Once you have created your Firebase project, we need to find your Cloud Messaging Server key. In the Firebase Console, click on the “gear” settings icon and then click on the “Cloud Messaging” tab.

You will need to copy this survey key and add it to your User Hook Push Settings through the User Hook admin website.

Initialize User Hook for Push Notifications

After creating your Firebase project, you will need to download the google-services.json file and save it to the “Assets/Plugins/Android” folder. After saving the google-services.json file, you will need to click on the User Hook menu and click on “Prepare for Android Build”. This creates the necessary internal configuration files Android needs for push notifications.

Handling Push Notification Payloads

When your android app receives a push notification, it will have access to the Payload data that was defined in the User Hook admin site. If your app will be using this payload data, you will need to setup a payload handler.

Custom Notification Icon

By default, User Hook will use your application’s icon as the icon shown in push notifications. You may set a custom notification icon while initializing User Hook. You will need to save your custom notification icon at “Assets/Plugins/Android/custom-push-icon/res/drawable/notification.png”. Then when initializing User Hook in your scene, you will need to add the following code.