Search Issue Tracker
Fixed in 5.4.2
Votes
1
Found in
5.4.0f3
Issue ID
830528
Regression
Yes
[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);
OR
Set UNITY_USES_REMOTE_NOTIFICATIONS to 1 in Preprocessor.h script in Xcode project.
Reproduced on:
5.5.0b4, 5.4.1p1
Did not reproduce:
5.3.6p5, 5.3.6p3, 5.2.4f1
Comments (2)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [UI Builder] Viewport's gizmos for Margin and Padding disappear when dragging to modify the value and the cursor leaves the Spacing section
- "Multiplayer Center" window does not reflect changes made in "Other Packages" section
- Crash on D3DKMTOpenResource when capturing with RenderDoc while GPU Skinning is set to GPU(Batched)
- Editing and saving Curve changes in UI Builder window throws multiple errors in the Console
- [UI Builder] Value is not selected when left clicking on Spacing/Border Widget values
ratmat2002
Jan 06, 2017 00:40
I'm still seeing this same problem of deviceToken being null on Unity 5.5.0p3. I have tried everything.
UNITY_USES_REMOTE_NOTIFICATIONS is set to 1 in Preprocessor.h but it still doesn't work.
Has anyone gotten this to work on Unity 5.5?
DukeZagarth
Oct 12, 2016 22:07
Currently the last release of Unity is 5.4.1 and I can reproduce this bug in Unity 5.4.1f1 and 5.4.1p3, how can I get a Unity version that fix this issue?