Skip to main content
Version: 5.9.6

PutDeviceToken

public BackendReturnObject PutDeviceToken();
public BackendReturnObject PutDeviceToken(string deviceToken);

Parameter

ValueTypeDescription
deviceTokenstringInformation about the local device. You can obtain it through the Backend.Android.GetDeviceToken() method.

Description

Turns on the push message setting.
When the push message setting is turned on, push notifications will arrive when BACKND Console uses the push message function.
For more information on push message registration, refer to the Android push registration guide.

The corresponding method has different parameter values for synchronous and asynchronous methods.

Example

Synchronous

Backend.Android.PutDeviceToken();

Asynchronous

Backend.Android.PutDeviceToken(Backend.Android.GetDeviceToken(), (callback) => 
{
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.Android.PutDeviceToken, Backend.Android.GetDeviceToken(), (callback) => 
{
// Post-process
});

Return cases

Success cases

When registration is successful
statusCode : 204

Error cases

When the token information about the push message is invalid(e.g., string.Empty, null, etc.)
statusCode : 400
errorCode : UndefinedParameterException

An error may occur if Firebase SDK or google-services.json file was not installed properly.
Make sure to check if the value is a randomly-generated string value via Backend.Android.GetDeviceToken().
When string.Empty appears, reinstall Firebase SDK or the JSON file by following the steps below:

  • Re-import FirebaseMessaging.unitypackage
  • Organize plugins(Assets > External Dependency Manager > Android Resolver > Force Resolve)
  • Check if Firebase's package name settings match Unity's package name settings
  • Re-apply the google-services.json file provided by Firebase