private void OnAuthorizationRequestHandler() { _requestAuthorization.onClick.RemoveListener(OnAuthorizationRequestHandler); LocalNotificationController.AuthorizationRequestResultEvent += AuthorizationRequestResultHandler; LocalNotificationController.RequestAuthorization(AuthorizationOption.Alert | AuthorizationOption.Badge | AuthorizationOption.Sound | AuthorizationOption.Provisional); }
private void ScheduleLocalNotificationHandler() { LocalNotificationController.ScheduleNotification(new Notification { Title = "Test title", Body = "Test body", Data = "Test data", FireInSeconds = Random.Range(1, 5), Icon = "Icon" }); }
public IEnumerator Start() { #if UNITY_IOS _areNotificatonsEnabled.text = string.Format(NOTIFICATION_ENABLED_TEXT, LocalNotificationController.AreNotificationsEnabled().ToString()); LocalNotificationController.Initialize(NotificationPresentationOptions.Alert | NotificationPresentationOptions.Badge | NotificationPresentationOptions.Sound); #endif #if UNITY_ANDROID UpdateNotificationStatus(); var notificationChannel = new NotificationChannel(); notificationChannel.Id = "id"; notificationChannel.Name = "notification_channel"; notificationChannel.Description = "desc"; notificationChannel.Importance = Importance.High; notificationChannel.ShowBadge = true; notificationChannel.Lights = true; notificationChannel.Vibration = true; LocalNotificationController.CreateNotificationChannel(notificationChannel); #endif UpdateOpenedByNotificationStatus(); LocalNotificationController.NotificationReceivedEvent += NotificationReceivedHandler; #if UNITY_IOS LocalNotificationController.DeviceTokenReceived += DeviceTokenReceived; _requestAuthorization.onClick.AddListener(OnAuthorizationRequestHandler); #endif _scheduleNotification.onClick.AddListener(ScheduleLocalNotificationHandler); _removeScheduledNotifications.onClick.AddListener(OnRemoveScheduledNotifications); _removeDeliveredNotifications.onClick.AddListener(OnRemoveDeliveredNotifications); yield return(new WaitForEndOfFrame()); UpdateBackgroundNotifications(LocalNotificationController.ReceivedNotifications); }
private void UpdateOpenedByNotificationStatus() { _isOpenedByNotification.text = string.Format(IS_OPENED_BY_NOTIFICATION_TEXT, (LocalNotificationController.GetLastNotification() != null).ToString()); }
private void OnRemoveDeliveredNotifications() { LocalNotificationController.RemoveDeliveredNotifications(); }
private void OnRemoveScheduledNotifications() { LocalNotificationController.RemoveScheduledNotifications(); }
private void UpdateNotificationStatus() { _areNotificatonsEnabled.text = string.Format(NOTIFICATION_ENABLED_TEXT, LocalNotificationController.AreNotificationsEnabled().ToString()); }