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 UpdateNotificationStatus() { _areNotificatonsEnabled.text = string.Format(NOTIFICATION_ENABLED_TEXT, LocalNotificationController.AreNotificationsEnabled().ToString()); }