Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public class LocalPush : MonoBehaviour
- {
- void Start()
- {
- // NotificationServices.CancelAllLocalNotifications(); // To cancel all Notifications (If Needed).
- ScheduleNotificationForiOSWithMessage(“It Works!",System.DateTime.Now.AddSeconds(5f));
- }
- void ScheduleNotificationForiOSWithMessage (string text, System.DateTime fireDate)
- {
- if (Application.platform == RuntimePlatform.IPhonePlayer)
- {
- UnityEngine.iOS.LocalNotification notification = new UnityEngine.iOS.LocalNotification ();
- notification.fireDate = fireDate;
- notification.alertAction = "Alert";
- notification.alertBody = text;
- notification.hasAction = false;
- UnityEngine.iOS.NotificationServices.ScheduleLocalNotification (notification);
- #if UNITY_IOS
- UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Alert );
- UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Badge );
- nityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotifiationType.Sound );
- #endif
- }
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement