Raf avatar image
Raf asked

UnityEngine.iOS.NotificationServices deprecated in Unity 2022


We're updating our project to Unity 2022.3.7f1 and the class UnityEngine.iOS.NotificationServices seems to no longer be part of Unity.

We already currently have push notifications working on iOS using the snippet provided in PlayFab's documentation (using Unity 2021) but there is nothing mentioning newer versions of Unity.

The current documentation converts devicetoken (byte[]) into a string as shown below:

 byte[] token = UnityEngine.iOS.NotificationServices.deviceToken;
     request.DeviceToken = System.BitConverter.ToString(token).Replace("-", "").ToLower();

Since UnityEngine.iOS.NotificationServices.deviceToken is no longer available, i've tried using the string value from Firebase.Messaging.TokenReceivedEventArgs instead, like this:

 request.DeviceToken = token.DeviceToken;

and like this:

 request.DeviceToken = token.DeviceToken.Replace("-", "").ToLower();

but neither of them worked.

Could there be a difference in formatting when converting a string from a byte[] type (as it's done in the current documentation)? Or could it be that the device token passed in Firebase.Messaging.TokenReceivedEventArgs is not the same one used by PlayFab as in UnityEngine.iOS.NotificationServices.deviceToken?

Thanks in advance! Any help here will be much appreciated as this is the only issue impending us from updating our app.

unity3dsdksPush Notifications
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

Xiao Zha avatar image
Xiao Zha answered

The token in “Firebase.Messaging.TokenReceivedEventArgs” is different from the device token in “UnityEngine.iOS.NotificationServices.deviceToken”. And since Unity provide the Introduction | Mobile Notifications | 2.2.1 ( for you, you may refer to iOS notifications | Mobile Notifications | 2.2.1 ( to get the device token. In addition, we are not the experts in IOS notification service, you may seek professional help from Unity or Apple support team.

1 comment
10 |1200

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

Raf avatar image Raf commented ·

Thanks for the answer!

It works now after using DeviceToken from AuthorizationRequest as shown in the Unity documentation you referred. Thanks!

I just think that it would be useful to others in the future if PlayFab's example was updated adding the context when using Unity 2022 and above, as the current example won't even compile using Unity later versions. It also can be confusing as Firebase returns a different device token that should only be used for Android.

And in the case anyone reads this in the future, I'm not sure if it's required to modify the device token string but that is what made ours work:

 var request = new AuthorizationRequest(AuthorizationOption.Badge
             | AuthorizationOption.Sound | AuthorizationOption.Alert, true);
 string deviceToken_iOS = request.DeviceToken.Replace("-", "").ToLower();
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.