protected override void AddNotificationRequestInternal(UM_NotificationRequest request, Action <SA_Result> callback)
        {
            var content = new ISN_UNNotificationContent();

            content.Title = request.Content.Title;
            content.Body  = request.Content.Body;
            if (request.Content.BadgeNumber != -1)
            {
                content.Badge = request.Content.BadgeNumber;
            }


            if (string.IsNullOrEmpty(request.Content.SoundName))
            {
                content.Sound = ISN_UNNotificationSound.DefaultSound;
            }
            else
            {
                content.Sound = ISN_UNNotificationSound.SoundNamed(request.Content.SoundName);
            }

            ISN_UNNotificationTrigger trigger = null;

            if (request.Trigger is UM_TimeIntervalNotificationTrigger)
            {
                var timeIntervalTrigger = (UM_TimeIntervalNotificationTrigger)request.Trigger;
                trigger = new ISN_UNTimeIntervalNotificationTrigger(timeIntervalTrigger.Interval, timeIntervalTrigger.Repeating);
            }

            var ios_request = new ISN_UNNotificationRequest(request.Identifier.ToString(), content, trigger);

            ISN_UNUserNotificationCenter.AddNotificationRequest(ios_request, callback);
        }
Пример #2
0
        protected override void AddNotificationRequestInternal(UM_NotificationRequest request, Action <SA_Result> callback)
        {
            try
            {
                var builder = new AN_NotificationCompat.Builder();
                builder.SetContentTitle(request.Content.Title);
                builder.SetContentText(request.Content.Body);
                if (request.Content.BadgeNumber != -1)
                {
                    builder.SetNumber(request.Content.BadgeNumber);
                }

                if (string.IsNullOrEmpty(request.Content.SoundName))
                {
                    builder.SetDefaults(AN_Notification.DEFAULT_LIGHTS | AN_Notification.DEFAULT_SOUND);
                }
                else
                {
                    string soundName = SA_AssetDatabase.GetAssetNameWithoutExtension(request.Content.SoundName);
                    builder.SetSound(soundName);
                }


                if (!string.IsNullOrEmpty(request.Content.IconName))
                {
                    string iconName = SA_AssetDatabase.GetAssetNameWithoutExtension(request.Content.IconName);
                    builder.SetSmallIcon(iconName);
                }

                if (request.Content.LargeIcon != null)
                {
                    builder.SetLargeIcon(request.Content.LargeIcon);
                }


                UM_TimeIntervalNotificationTrigger timeIntervalTrigger = (UM_TimeIntervalNotificationTrigger)request.Trigger;

                var trigger = new AN_AlarmNotificationTrigger();
                trigger.SetDate(TimeSpan.FromSeconds(timeIntervalTrigger.Interval));
                trigger.SerRepeating(timeIntervalTrigger.Repeating);

                var android_request = new AN_NotificationRequest(request.Identifier, builder, trigger);

                AN_NotificationManager.Schedule(android_request);

                callback.Invoke(new SA_Result());
            } catch (Exception ex) {
                var error = new SA_Error(100, ex.Message);
                callback.Invoke(new SA_Result(error));
            }
        }
        public UM_IOSNotificationsClient()
        {
            ISN_UNUserNotificationCenterDelegate.WillPresentNotification.AddListener((ISN_UNNotification notification) => {
                UM_NotificationRequest request = ToUMRequest(notification.Request);
                m_onNotificationReceived.Invoke(request);
            });

            ISN_UNUserNotificationCenterDelegate.DidReceiveNotificationResponse.AddListener((ISN_UNNotificationResponse responce) => {
                if (responce.ActionIdentifier.Equals(ISN_UNNotificationAction.DefaultActionIdentifier))
                {
                    UM_NotificationRequest request = ToUMRequest(responce.Notification.Request);
                    m_onNotificationClick.Invoke(request);
                }
            });
        }
Пример #4
0
        private UM_NotificationRequest ToUMRequest(AN_NotificationRequest android_request)
        {
            var content = new UM_Notification();

            content.SetTitle(android_request.Content.Title);
            content.SetBody(android_request.Content.Text);

            var interval            = (long)android_request.Trigger.Seconds;
            var repeating           = android_request.Trigger.Repeating;
            var timeIntervalTrigger = new UM_TimeIntervalNotificationTrigger(interval);

            timeIntervalTrigger.SerRepeating(repeating);

            var request = new UM_NotificationRequest(android_request.Identifier, content, timeIntervalTrigger);

            return(request);
        }
        private UM_NotificationRequest ToUMRequest(ISN_UNNotificationRequest ios_request)
        {
            var content = new UM_Notification();

            content.SetTitle(ios_request.Content.Title);
            content.SetBody(ios_request.Content.Body);

            var timeIntervalTrigger = (ISN_UNTimeIntervalNotificationTrigger)ios_request.Trigger;


            var interval  = timeIntervalTrigger.TimeInterval;
            var repeating = timeIntervalTrigger.Repeats;
            var trigger   = new UM_TimeIntervalNotificationTrigger(interval);

            trigger.SerRepeating(repeating);

            var Identifier = Convert.ToInt32(ios_request.Identifier);
            var request    = new UM_NotificationRequest(Identifier, content, trigger);

            return(request);
        }
 public void AddNotificationRequest(UM_NotificationRequest request, Action <SA_Result> callback)
 {
     AddNotificationRequestInternal(request, callback);
 }
 protected abstract void AddNotificationRequestInternal(UM_NotificationRequest request, Action <SA_Result> callback);
 protected override void AddNotificationRequestInternal(UM_NotificationRequest request, Action <SA_Result> callback)
 {
     SA_Coroutine.WaitForSeconds(1f, () => {
         callback.Invoke(new SA_Result());
     });
 }