How to cancel iOS LocalNotification?
Hello, I want to ask how to cancel iOS LocalNotification.
I used this code :
 #if UNITY_IOS
 if (Application.platform == RuntimePlatform.IPhonePlayer)
 {
    UnityEngine.iOS.LocalNotification iOSNotification = new UnityEngine.iOS.LocalNotification();
    iOSNotification.fireDate = fireDate;
    iOSNotification.alertBody = String.Format("Oven {0} done!!", ovenNumber);
    UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(iOSNotification);
  }
 #endif
and this worked right.
After this, I wanted to check how many LocalNotifications exist and store all LocalNotifications in list.
I used this code :
 UnityEngine.iOS.LocalNotification[] localNotifications = UnityEngine.iOS.NotificationServices.localNotifications;
 Debug.Log("Number of localNotifications = " + UnityEngine.iOS.NotificationServices.localNotificationCount);
 for (int i = 0; i < localNotifications.Count(); i++)
 {
     Debug.Log("localNotification[" + i + "] = " + localNotifications[i].fireDate);
 }
I ran this code after I registered 3 LocalNotifications but it resulted like this:
Number of localNotifications = 0 (prints nothing in for loop)
UnityEngine.iOS.NotificationServices.localNotifications always returns 0 UnityEngine.iOS.NotificationServices.localNotificationCount always returns 0
So, I can't find out how many LocalNotifications are registered when I restart the application And I can't cancel the LocalNotification because I can't get the LocalNotification instances.
Then how can I cancel specific LocalNotification?
Answer by sirua · Jun 15, 2017 at 09:57 AM
You try UnityEngine.iOS.NotificationServices.scheduledLocalNotifications .
Your answer
 
 
             Follow this Question
Related Questions
Cannot obtain apns token in Unity 5.4.0 2 Answers
*SOLVED* Error writing to IOS file system works on android & editor 1 Answer
Use UserNotification (iOS 10) in C# 0 Answers
iOS moving up and down question ( code problem ) 0 Answers
How to Schedule a Remote Notification daily at certain time. 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                