After calling NotificationServices.RegisterForNotifications in new Unity 5.4.0f3 deviceToken is not received and registrationError also is null. In Unity 5.3.6 it works fine. Maybe anyone can provide a solution for this problem?
That’s a known bug which is being solved as you can see here: Unity Issue Tracker - [iOS] Push Notifications not Enabled in Xcode Project when NotificationServices are used
There is a workaround that could help in the meantime:
You must insert the following line before calling “RegisterForNotifications”:
var unused_var = typeof(UnityEngine.iOS.RemoteNotification);
For example your MonoBehaviour’s start function could look like this:
void Start () {
var unused_var = typeof(UnityEngine.iOS.RemoteNotification);
tokenSent = false;
NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound, true);
}
The statement will change the value of the preprocessor directive “UNITY_USES_REMOTE_NOTIFICATIONS” from default 0 to 1, at “Preprocessor.h” in the trampoline Xcode project.
Another way to do that is manually change the “#define UNITY_USES_REMOTE_NOTIFICATIONS” value to 1.
I hope that helps!
Thanks a lot for response! If to change this directive manually what is the exact place to do it (unity class or xcode project)?