NotificationServices is only available on iPhoneiPadiPod Touch.
void RemoveAllNotifications() { #region Android #if UNITY_ANDROID string raw = PlayerPrefs.GetString("NotificationIDs"); if (!string.IsNullOrEmpty(raw)) { notification_ids = raw.Split(',').Select(x => x.Split(':')).ToDictionary(x => x[0], x => int.Parse(x[1])); } else { return; } foreach (var key in notification_ids.Values) { AndroidLocalNotification.CancelNotification(key); } notification_ids.Clear(); PlayerPrefs.DeleteKey("NotificationIDs"); #endif #endregion #region iOS #if UNITY_IOS NotificationServices.CancelAllLocalNotifications(); #endif #endregion }
// Call by main game OnApplicationPause public void ScheduleReturnBackToGameNotification() { #if UNITY_ANDROID NotificationParams notification = new NotificationParams { Id = NotificationIdHandler.GetNotificationId(), Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, LargeIcon = "app_icon", SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), CallbackData = "ScheduleReturnBackToGameNotification", // name of method Delay = TimeSpan.FromSeconds(inactiveLatelyNotificationDelayInSeconds), Title = androidAppTitle, Message = inactiveLatelyMessage }; NotificationManager.SendCustom(notification); #elif UNITY_IOS LocalNotification notification = new LocalNotification { applicationIconBadgeNumber = 1, alertBody = inactiveLatelyMessage, fireDate = DateTime.Now.AddSeconds(inactiveLatelyNotificationDelayInSeconds), soundName = LocalNotification.defaultSoundName }; NotificationServices.ScheduleLocalNotification(notification); #endif }
public void InitIOS() { Notification.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); }
private void sendNotification(int id, TimeSpan delay, string title, string text, Color32 color) { var notificationParams = new NotificationParams { Id = id, Delay = delay, Title = title, Message = text, //Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Bell, SmallIconColor = new Color(0.5f, 0.5f, 0.5f), LargeIcon = "app_icon" }; NotificationManager.SendCustom(notificationParams); //NotificationManager.SendWithAppIcon(delay, title, text, new Color(0, 0.6f, 1), NotificationIcon.Bell); //NotificationManager.Send(delay, title, text, new Color(0, 0.6f, 1)); //LocalNotification.SendNotification(id, delay, title, text, color); #if UNITY_IOS if (Application.platform == RuntimePlatform.IPhonePlayer) { UnityEngine.iOS.LocalNotification notification = new UnityEngine.iOS.LocalNotification(); notification.fireDate = DateTime.Now.Add(delay); notification.alertAction = "Alert"; notification.alertBody = text; notification.hasAction = false; NotificationServices.ScheduleLocalNotification(notification); } #endif }
public static void RegisterNotificationSettings() { NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); }
private void Update() { // no point checking if we don't have a device token yet if (this.deviceToken == null) { return; } this.currentQueryTime += Time.deltaTime; // early out if haven't met the query time if (this.currentQueryTime < QueryTimerMax) { return; } // reset timer this.currentQueryTime = 0.0f; // https://forum.unity3d.com/threads/using-the-new-notification-system.127016/ if (NotificationServices.remoteNotificationCount != 0) { // iterating over all the remote notifications for (int i = 0; i < NotificationServices.remoteNotificationCount; i++) { this.pushHandler.ReceivedPushNotification(NotificationServices.GetRemoteNotification(i).alertBody); } // clear all messages NotificationServices.ClearRemoteNotifications(); NotificationServices.ClearLocalNotifications(); } }
// Use this for initialization void Start() { Debug.Log("ctrAnalyticsClass start"); //local notification for iOS //tokenSent = false; #if UNITY_IOS NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); #endif //AppsFlyer /* Mandatory - set your AppsFlyer’s Developer key. */ Debug.Log("AppsFlyer init"); AppsFlyer.setAppsFlyerKey("Ura5UVbFB3YXvaig2PnvPA"); /* For detailed logging */ //AppsFlyer.setIsDebug (true); #if UNITY_IOS /* Mandatory - set your apple app ID * NOTE: You should enter the number only and not the "ID" prefix */ AppsFlyer.setAppID("1440167499"); AppsFlyer.trackAppLaunch(); #elif UNITY_ANDROID /* Mandatory - set your Android package name */ AppsFlyer.setAppID("com.evogames.feedthespider"); /* For getting the conversion data in Android, you need to add the "AppsFlyerTrackerCallbacks" listener.*/ AppsFlyer.init("Ura5UVbFB3YXvaig2PnvPA", "AppsFlyerTrackerCallbacks"); #endif }
/// <summary> /// Registruje aplikaciju za setovanje i primanje lokalnih notifikacija na IOS-u. /// </summary> public void RegisterForLocalNottifications() { #if UNITY_IOS && !UNITY_EDITOR //za tip notifikacije promeniti argument funkcije //ovo je default poziv NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); #endif }
public void PostIOSLocalNotification(DateTime time, string message) { var notif = new Local(); notif.fireDate = time; notif.alertBody = message; Notification.ScheduleLocalNotification(notif); }
public static RemoteNotification GetRemoteNotification(int index) { if (index < 0 || index >= NotificationServices.remoteNotificationCount) { throw new ArgumentOutOfRangeException("index", "Index out of bounds."); } return(NotificationServices.GetRemoteNotificationImpl(index)); }
private void RequestRegistreNotifications() { // iOS #if UNITY_IOS Debug.Log("Request Notifications iOS"); NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); #endif }
public void RequireNotificationsPremissions() { DontAskForNotifications(); NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); }
public void AddNotification() { #if UNITY_IOS LocalNotification l = new LocalNotification(); l.applicationIconBadgeNumber = 1; l.fireDate = System.DateTime.Now.AddSeconds(pushSeconds[0]); NotificationServices.ScheduleLocalNotification(l); #endif }
void Awake() { #if UNITY_IOS NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); #endif }
public static void SetNotification(string message, int delayTime, int badgeNumber = 1) { var l = new LocalNotification(); l.applicationIconBadgeNumber = badgeNumber; l.fireDate = System.DateTime.Now.AddSeconds(delayTime); l.alertBody = message; NotificationServices.ScheduleLocalNotification(l); }
public void ScheduleLocalPushNotification(string title, string message, DateTime dateTime) { NotificationServices.ScheduleLocalNotification(new UnityEngine.iOS.LocalNotification() { alertAction = title, alertBody = message, fireDate = dateTime, }); }
private void cancelNotification() { NotificationManager.CancelAll(); //LocalNotification.ClearNotifications(); #if UNITY_IOS NotificationServices.CancelAllLocalNotifications(); NotificationServices.ClearLocalNotifications(); #endif }
public static LocalNotification GetLocalNotification(int index) { bool flag = index < 0 || index >= NotificationServices.localNotificationCount; if (flag) { throw new ArgumentOutOfRangeException("index", "Index out of bounds."); } return(NotificationServices.GetLocalNotificationImpl(index)); }
public void ClearNotification() { #if UNITY_IOS LocalNotification l = new LocalNotification(); l.applicationIconBadgeNumber = -1; NotificationServices.PresentLocalNotificationNow(l); NotificationServices.CancelAllLocalNotifications(); NotificationServices.ClearLocalNotifications(); #endif }
//public class LocalNoticeScript { // Use this for initialization void Start() { #if UNITY_IOS NotificationServices.RegisterForNotifications( UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound ); #endif }
void Start() { sendNotif = 7; tokenSent = false; NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); }
void Start() { #if UNITY_IOS // Register for iOS local notifications Debug.Log("Registering iOS notifications"); NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); #endif // Schedule notification on start ScheduleLocalNotification(); }
public void DisableNotify() { #if UNITY_ANDROID AndroidNotificationManager.Instance.CancelAllLocalNotifications(); ReceivePushNotifications = false; #endif #if UNITY_IOS Notification.CancelAllLocalNotifications(); ReceivePushNotifications = false; #endif }
/// <summary> /// Uklanja sve setovane lokalne notifikacije (Samo IOS) /// </summary> public void CancelAllNotifications() { #if UNITY_IOS && !UNITY_EDITOR //Empty notification to clear badge number LocalNotification l = new LocalNotification(); l.applicationIconBadgeNumber = -1; NotificationServices.PresentLocalNotificationNow(l); NotificationServices.CancelAllLocalNotifications(); NotificationServices.ClearLocalNotifications(); NotificationServices.ClearLocalNotifications(); #endif }
private void SetNotify() { foreach (var info in notifications.Values) { var localNotification = new LocalNotification(); localNotification.fireDate = info.UnixTime.UnixTimeToDateTime(); localNotification.alertBody = info.Message; localNotification.alertAction = info.Title; NotificationServices.ScheduleLocalNotification(localNotification); } }
public IEnumerator AskForPermissionsCoroutine() { yield return(new WaitForSeconds(popupCloseDelay)); #if UNITY_ANDROID // 1. RegisterForNotifications via manifest // 2. Assuming it's allowed on install //analyticsController.SendNotificationPermissionsResult(true); #elif UNITY_IOS NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); StartCoroutine(CheckForiOSPermissionOutcome()); #endif }
public void ClearNotifications() { if (!isCleared) { #if UNITY_IOS NotificationServices.CancelAllLocalNotifications(); #endif #if UNITY_ANDROID Assets.SimpleAndroidNotifications.NotificationManager.CancelAll(); #endif isCleared = true; } }
public static void ClearNotification() { #if UNITY_IOS mIconBadgeNumber = 0; CancelAllLocalNotifications(); ClearLocalNotifications(); LocalNotification localNotification = new LocalNotification(); localNotification.applicationIconBadgeNumber = -1; NotificationServices.PresentLocalNotificationNow(localNotification); NotificationServices.CancelAllLocalNotifications(); NotificationServices.ClearLocalNotifications(); #endif }
private IEnumerator Start() { NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound, true); int retryCount = 0; while (this.deviceToken == null) { if (this.deviceToken == null && NotificationServices.deviceToken != null) { this.deviceToken = BitConverter.ToString(NotificationServices.deviceToken).Replace("-", "").ToLower(); } retryCount++; if (retryCount > RetryCountMax) { yield break; } yield return(new WaitForSeconds(RetryWaitTime)); } // if we got here and still no deviceToken, then we timed out if (this.deviceToken == null) { Debug.LogError("PlayFabIOSPushHandler timed out waiting for the deviceToken."); // cleaning up this iOS push notification handler so it doesn't take up any cycles GameObject.Destroy(this); yield break; } PlayFabClientAPI.RegisterForIOSPushNotification( new RegisterForIOSPushNotificationRequest { DeviceToken = this.deviceToken }, (result) => { Debug.Log("Push Notification Registration Successful!"); }, (error) => { Debug.Log("Error Registering for iOS Push Notifications!"); Debug.Log(error.Error); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
public IEnumerator AskForPermissionsCoroutine() { print("[NOTIFICATION] Ask permissions"); yield return(new WaitForSeconds(postGameWindowClosedDelay)); #if UNITY_ANDROID // 1. RegisterForNotifications via manifest // 2. Assuming it's allowed on install //analyticsController.SendNotificationPermissionsResult(true); #elif UNITY_IOS NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); #endif }