- Home /
iOS Setting Icon Badge Number With Local Notification
Was anyone successful in setting the icon badge number using iOS.LocalNotification.applicationIconBadgeNumber
?
Using the following code, notifications are displayed (with the body text and sound alert) on the iOS device but the icon badge number of the application doesn't reflect the badge number set:
UnityEngine.iOS.LocalNotification localNotification = new UnityEngine.iOS.LocalNotification();
localNotification.applicationIconBadgeNumber = 1;
localNotification.alertBody = bodyText;
localNotification.fireDate = fireDate;
localNotification.soundName = UnityEngine.iOS.LocalNotification.defaultSoundName;
UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(localNotification);
Also tried without setting the applicationIconBadgeNumber
property, to no avail.
Answer by jderrough · Nov 11, 2015 at 01:14 AM
Found it, the register call was missing the NotificationType.Badge
flag:
UnityEngine.iOS.NotificationServices.RegisterForNotifications(UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Sound | UnityEngine.iOS.NotificationType.Badge);
All better now. :)
Your answer
Follow this Question
Related Questions
Time.deltaTime not running in background (for local notification) 2 Answers
Local notification with closed app 3 Answers
iOS.LocalNotification not saving variables after being set 1 Answer
Reading notifications from Unity or knowing if notifications are enabled 0 Answers
How can I respond to push notifications when app isn't running? 0 Answers