Search Issue Tracker
Fixed in 5.4.2
[iOS] NotificationServices.RegisterForNotifications does not return the device token from Apple Push Service
When using NotificationServices.RegisterForNotifications to receive the device token from Apple Push Service, the value returned by NotificationServices.deviceToken is always 'null'. This happens because UNITY_USES_REMOTE_NOTIFICATIONS is not set to 1 in Preprocessor.h in Xcode project.
Steps to reproduce:
1) Open the attached project (NotificationToken.zip).
2) Build the 'Test' scene for iOS.
3) Run on a device via Xcode.
4) When prompted to allow push notifications, press 'OK'.
When the app launches, messages are logged in the Xcode console, saying that the device token was not received; the value of NotificationServices.deviceToken is 'null'. With Unity 5.3 and older, the device token is returned and printed in the console.
Workaround - declare an instance of RemoteNotification class before registering for remote notifications:
var unused = typeof(UnityEngine.iOS.RemoteNotification);
Set UNITY_USES_REMOTE_NOTIFICATIONS to 1 in Preprocessor.h script in Xcode project.
Did not reproduce:
5.3.6p5, 5.3.6p3, 5.2.4f1
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- NullReferenceExceptions are being thrown when saving a ScriptableObject with an array of a type with a CustomPropertyDrawer that uses TrackPropertyValue
- Applied velocity is inconsistent when using Rigidbody AddForce() with ForceMode.VelocityChange
- Crash on AudioUtil_CUSTOM_HasAudioCallback when exiting Play Mode while the Inspector is displaying a GameObject with an empty script attached
- Scroll offset is framerate-dependent when scrolling with velocity in the Device Simulator
- "Object.FindObjectsOfType<T>() is obsolete" warning is thrown when using "Transitions Plus" asset