コード例 #1
0
        private void OnAuthorizationRequestHandler()
        {
            _requestAuthorization.onClick.RemoveListener(OnAuthorizationRequestHandler);

            LocalNotificationController.AuthorizationRequestResultEvent += AuthorizationRequestResultHandler;

            LocalNotificationController.RequestAuthorization(AuthorizationOption.Alert | AuthorizationOption.Badge | AuthorizationOption.Sound | AuthorizationOption.Provisional);
        }
コード例 #2
0
 private void ScheduleLocalNotificationHandler()
 {
     LocalNotificationController.ScheduleNotification(new Notification
     {
         Title         = "Test title",
         Body          = "Test body",
         Data          = "Test data",
         FireInSeconds = Random.Range(1, 5),
         Icon          = "Icon"
     });
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 private void UpdateOpenedByNotificationStatus()
 {
     _isOpenedByNotification.text = string.Format(IS_OPENED_BY_NOTIFICATION_TEXT,
                                                  (LocalNotificationController.GetLastNotification() != null).ToString());
 }
コード例 #5
0
 private void OnRemoveDeliveredNotifications()
 {
     LocalNotificationController.RemoveDeliveredNotifications();
 }
コード例 #6
0
 private void OnRemoveScheduledNotifications()
 {
     LocalNotificationController.RemoveScheduledNotifications();
 }
コード例 #7
0
 private void UpdateNotificationStatus()
 {
     _areNotificatonsEnabled.text = string.Format(NOTIFICATION_ENABLED_TEXT,
                                                  LocalNotificationController.AreNotificationsEnabled().ToString());
 }