PutDeviceToken
public BackendReturnObject PutDeviceToken(isDevelopment isDev);\ public BackendReturnObject PutDeviceToken(string deviceToken, isDevelopment isDev);
Parameter
Value | Type | Description |
---|---|---|
isDev | isDevelopment | isDevelopment.iosDev (value to be used as a test version) or isDevelopment.iosProd (value to be used for actual deployment) |
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.\ Push message is set to disable nighttime push notifications by default. To change this setting, refer to the AgreeNightPushNotification method.\ For more information on push message registration, refer to the iOS Push Registration Guide.
isDevelopment가 iosProd일 경우, 프로비저닝 인증서를 통해 앱을 배포한 후 마켓에서 해당 앱을 다운로드해야지만 푸시 알람이 정상적으로 작동합니다.
How to get device token
Install Mobile Notifications from the Package Manager
At the top of Unity, click Window > Package Manager.
Change the 'Packages' category to 'Unity Registry' and search for Mobile Notifications.\ Click it, then call Install.
Mobile Notifications settings
Check 'Enable Push Notifications' in Project Settings > Mobile Notifications > iOS.
Writes code to load the device token
using Unity.Notifications.iOS;
public class IOSPushFunction : MonoBehavior
{
private string token = string.Empty;
public void GetDeviceToken()
{
StartCoroutine(RequestAuthorization());
}
private IEnumerator RequestAuthorization()
{
var authorizationOption = AuthorizationOption.Alert | AuthorizationOption.Badge;
using (var req = new AuthorizationRequest(authorizationOption, true))
{
while (!req.IsFinished)
{
yield return null;
};
token = req.DeviceToken;
Debug.Log("IOS Push Token Created : " + token);
}
}
}
Example
Synchronous
// Refer to 'How to get device token' above for the token value.
Backend.iOS.PutDeviceToken(token, isDevelopment.iosDev);
Asynchronous
// Refer to 'How to get device token' above for the token value.
Backend.iOS.PutDeviceToken(token, isDevelopment.iosDev, (callback) =>
{
// Post-process
});
SendQueue
// Refer to the 'How to get device token' above for the token value
SendQueue.Enqueue(token, Backend.iOS.PutDeviceToken, isDevelopment.iosDev, (callback) =>
{
// Post-process
});
ReturnCase
Success cases
When registration is successful\ statusCode : 204\ message : Success