question

s_takamisawa@eve-sense.com avatar image
s_takamisawa@eve-sense.com asked

How to remove a device token for iOS UnityC# Playfab

I have set up a device token with "PlayFabClientAPI.RegisterForIOSPushNotification()" when setting up push notifications for iOS. Is there any way to cancel the registered device token? Also, can I see device token information on Playfab? When "registerForRemoteNotifications = false" in AuthorizationRequest setting, I got "Push Registration Successful" but the device token was not removed.

 public async void RegisterForIOSPushNotification()
 {
     AuthorizationOption authorizationOption;
     bool registerForRemoteNotifications;       
     if (registerForRemoteNotificationsFlg == true)
     {
         authorizationOption = AuthorizationOption.Alert | AuthorizationOption.Badge | AuthorizationOption.Sound;
         registerForRemoteNotifications = true;
     }
     else
     {
         authorizationOption = 0;
         registerForRemoteNotifications = false;
     }

     using (var req = new AuthorizationRequest(authorizationOption, registerForRemoteNotifications ))
     {
         await UniTask.WaitUntil(() => !req.IsFinished);
         if (req.Error != null)
         {
             Debug.LogError("req.ERROR:" + req.Error.ToString());
         }
         await UniTask.WaitUntil(() => req.DeviceToken != null);
         if (req.DeviceToken != null)
         {
             var request = new RegisterForIOSPushNotificationRequest
             {
                 DeviceToken = req.DeviceToken
             };
             PlayFabClientAPI.RegisterForIOSPushNotification(request,
             result =>
             {
                 Debug.Log("Push Registration Successful");
             },
             error =>
             {
                 Debug.Log(error.GenerateErrorReport());
             });
         }
         else
         {
             Debug.Log("Push Token was null!");
         }
     }

 }
unity3d
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Neils Shi avatar image
Neils Shi answered

The device token is generated by the Apple Push Notification service when registering to receive push notifications, it cannot be viewed on PlayFab. After registered, PlayFab does not support a feature to unregister the push notification or remove the device token. For more info, you can refer to this thread : How to unregister device from playfab push notifications?,How to un register device from playfab push notifications?,How can we un register device from push notifications? - Playfab Community. And since the device token has already been registered, the "registerForRemoteNotifications = false" in “AuthorizationRequest setting” does not delete it.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

s_takamisawa@eve-sense.com avatar image s_takamisawa@eve-sense.com commented ·

Thanks for the reply. I understand that the registered device token cannot be deactivated. I can expect that when I switch to a new device with a new model, if I keep the previous device token, push notifications will be sent to the old model. Is it possible to overwrite the device token instead of deactivating it?

I've looked at the thread you linked to, but I couldn't figure out how to "processes for players to "forget" this device, for example".

0 Likes 0 ·
Neils Shi avatar image Neils Shi s_takamisawa@eve-sense.com commented ·

As Seth mentioned in the thread : the player account can only register one device for push notification, so, if you log in in a new device and registers this device for push notification, only the new device will be able to receive notification. And the "processes for players to forget the device” is specific to Android (unlink device id and calling Firebase APIs to unregister).

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.