There seem to be an issue with unity 5.4 building for Xcode when you are using remote push notifications. You can register for push notifications but the callbacks returning the push-token or error is never called. After a lot of digging around i found that there is a compiler tag in Xcode that are always false (0). The delegates in Xcode listening for the token/error callbacks are defined inside this compiler tag. Adding the compiler tag in the buildsettings in unity does not work. The only solution is to make a precompiler script or modefy the value directly in Xcode. This must be a bug in Unity or there might be missing an option somewhere to enable/disable this.
The compiler tag: UNITY_USES_REMOTE_NOTIFICATIONS
Results in missing callback for didRegisterForRemoteNotificationsWithDeviceToken, meaning the devicetoken will never be available in unity.
I created this post mainly to help others with the issue and to ask Unity whats going on and if it is intended.
Check this link for a post-process script. Thanks @adamt_1
You have got to be kidding me. I lost a day (and an evening!) on this issue, and your fix worked perfectly, @BlaceX . It drives me absolutely insane that Unity can fundamentally break an existing feature in a new release, with no documentation about the macro and its existence, nor apparently any unit tests to cover the change.
For those of you struggling with this how to solve this problem, you might want to look at this Unity Answers thread for a working post-process script.
@adamt_1 glad to help, I posted because I spend a lot of time on it as well and there were no posts with solutions linked to the problem. If you searched for anything specific when looking for the issue please write it here so it can be added to the post. It will make it easier for others to find the solution when they search for it. It was making me crazy that it was so hard to google because the issue was touching so many areas.
I submitted one yesterday, but was told there is already one in-play. The sad part is that apparently this has been broken since beta 15 of 5.4, and Unity doesnât consider it a regression (how breaking an existing feature doesnât count as a regression is beyond me, but Iâm not a QA engineer so Iâll take their word for it), so the chance of it getting fixed, based on their new bug scoring system seems low.
There is a simpler 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:
voidStart(){
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.
You linked to the same bug Iâd already linked to in my post, so Iâm wondering if you meant to link to another bug? Like I mentioned, that particular bug has been open since April, isnât marked as a regression, and doesnât have any comments from Unity about its current status. So from our perspective, a proper fix may never see the light of day (you could argue that a bug listed as âActiveâ means youâre working on it, but 1.) thatâs not communicated anywhere in the issue tracker, and 2.) there are open bugs from 2014 that are also listed as active).
Do you have a fix version for this particular bug? Maybe adding a new âIn Progressâ status to the issue tracker would give us better visibility into whatâs going to be fixed, as opposed to keeping our fingers crossed with every patch release.
Thanks for the workaround. Adding that line of code works perfectly. No more manually changing the #define !
I hope you will fix the issue because it can take some time to identify what is going on when you try to use push. And if there is something developers never have it is time !
Sorry for the delay! Well, right now itâs hard to know an ETA or a milestone. What I can say is that Iâll post here the answer as soon as I get it.
This still seems to be broken in Unity 5.5.0p3 even with UNITY_USES_REMOTE_NOTIFICATIONS set to 1 and when trying the var unused_var =typeof(UnityEngine.iOS.RemoteNotification) hack.