- Home /
iOS local notifications never appear
Hi. I'm using Unity 4.3 and having a bit of a problem with getting local notifications on iOS to display. I'm using this code to schedule one:
var notification = new LocalNotification();
notification.fireDate = System.DateTime.Now.AddSeconds(10);
notification.alertBody = "Hello.";
NotificationServices.ScheduleLocalNotification(notification);
The notification never appears though. What exactly do I have to do besides using that code to get it to work? The documentation isn't mentioning anything, but maybe I need to change something in the app settings through XCode? Or maybe I need to add some more code elsewhere? Or maybe I need to add certain frameworks to the app?
At the moment, the notification is just completely absent no matter the lock state of the phone and no matter the state of the app (paused, closed). Unfortunately it's extremely hard to find any information about local notifications on the net besides official Unity and XCode docs as absolute majority of questions and threads are dedicated to push notifications which aren't exactly what I need.
P.S.: Besides, shouldn't I be seeing my game in the Notification Center section of iOS Settings app if notifications were working correctly? That's not happening either.
P.P.S.: I've heard there were some huge problems with how System.DateTime works on iOS in Unity 4.3 - could it be the reason for the issue (i.e. notifications are created correctly, but the scheduled time they get is completely wrong)? I'm building my XCode projects from PC, if that matters.
Answer by bac9-flcl · Mar 10, 2014 at 05:50 PM
Solved the issue. Turns out I was right - Windows-based XCode project generation is to blame (System.DateTime was indeed working incorrectly) and should be avoided. After building the project on Mac, notifications appeared and lots of other time-dependent functionality stopped dropping errors.
I sure hope Unity developers will fix it as soon as possible.