Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
703
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5.  
  6. public class LocalPush : MonoBehaviour
  7. {
  8.  
  9.  
  10. void Start()
  11. {
  12. // NotificationServices.CancelAllLocalNotifications(); // To cancel all Notifications (If Needed).
  13. ScheduleNotificationForiOSWithMessage(“It Works!",System.DateTime.Now.AddSeconds(5f));
  14. }
  15. void ScheduleNotificationForiOSWithMessage (string text, System.DateTime fireDate)
  16. {
  17. if (Application.platform == RuntimePlatform.IPhonePlayer)
  18. {
  19. UnityEngine.iOS.LocalNotification notification = new UnityEngine.iOS.LocalNotification ();
  20. notification.fireDate = fireDate;
  21. notification.alertAction = "Alert";
  22. notification.alertBody = text;
  23. notification.hasAction = false;
  24. UnityEngine.iOS.NotificationServices.ScheduleLocalNotification (notification);
  25.  
  26. #if UNITY_IOS
  27. UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Alert );
  28. UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Badge );
  29. nityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotifiationType.Sound );
  30. #endif
  31. }
  32. }
  33. }
Advertisement
RAW Paste Data Copied
Advertisement