LocalNotification not working

Hi,

I used the following code in unity script reference for scheduling a local notification.
function Start() { // schedule notification to be delivered in 10 seconds var notif = new LocalNotification(); notif.fireDate = DateTime.Now.AddSeconds(10); notif.alertBody = "Hello!"; NotificationServices.ScheduleLocalNotification(notif); } function Update() { if (NotificationServices.localNotificationCount > 0) { Debug.Log(NotificationServices.localNotifications[0].alertBody); NotificationServices.ClearLocalNotifications(); } }

But I get errors like
‘fireDate’ is not a member of ‘LocalNotification’.
‘alertBody’ is not a member of ‘LocalNotification’.
The best overload for the method ‘UnityEngine.NotificationServices.ScheduleLocalNotification(UnityEngine.LocalNotification)’ is not compatible with the argument list ‘(LocalNotification)’.
What am I doing wrong here. I am using unity 3.5.6f4. Do I need to use any additional settings in unity for make it working? Please help.

1 Answer

1

From your errors i guess it’s simply one of those “You named one of your classes or scriptfiles LocalNotification”.

Another reason could be that you don't compile for iOS. The [NotificationServices][1] class is only available for iOS. On Android it isn't supported yet AFAIK. [1]: http://docs.unity3d.com/Documentation/ScriptReference/NotificationServices.html

–

Yes. It was because I gave the file name as LocalNotification.

–