コード例 #1
0
        public void NotificationLocation()
        {
            var content = new ISN_UNNotificationContent();

            content.Title = "Hello";
            content.Body  = "Hello_message_body";
            content.Sound = ISN_UNNotificationSound.DefaultSound;


            var center = new ISN_CLLocationCoordinate2D(37.335400f, -122.009201f);
            var region = new ISN_CLCircularRegion(center, 2000f, "Headquarters");

            region.NotifyOnEntry = true;
            region.NotifyOnExit  = false;

            // Deliver the notification in five seconds.
            var trigger = new ISN_UNLocationNotificationTrigger(region, repeats: false);

            var request = new ISN_UNNotificationRequest("FiveSecond", content, trigger);


            // Schedule the notification.
            ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
            });
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void AddNotificationRequest(ISN_UNNotificationRequest request, Action <SA_Result> callback)
 {
     m_onAddNotificationRequest = callback;
     #if (UNITY_IPHONE || UNITY_TVOS) && USER_NOTIFICATIONS_API_ENABLED
     _ISN_UN_AddNotificationRequest(JsonUtility.ToJson(request));
     #endif
 }
コード例 #4
0
        void DocsExample()
        {
            var content = new ISN_UNNotificationContent();

            content.Title = "Wake up!";
            content.Body  = "Rise and shine! It's morning time!";

            content.Sound = ISN_UNNotificationSound.DefaultSound;
            content.Sound = ISN_UNNotificationSound.SoundNamed("MySound.wav");

            ISN_NSDateComponents date = new ISN_NSDateComponents();

            date.Hour   = 7;
            date.Minute = 0;


            var trigger = new ISN_UNCalendarNotificationTrigger(date, false);

            // Create the request object.
            string identifier = "MorningAlarm";
            var    request    = new ISN_UNNotificationRequest(identifier, content, trigger);



            ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                if (result.IsSucceeded)
                {
                    Debug.Log("Notification Request Added. ");
                }
                else
                {
                    Debug.Log("Error: " + result.Error.Message);
                }
            });



            ISN_UNUserNotificationCenterDelegate.WillPresentNotification.AddListener((ISN_UNNotification notification) => {
                //Do something
            });


            var notificationResponse = ISN_UNUserNotificationCenterDelegate.LastReceivedResponse;

            ISN_UIApplication.RegisterForRemoteNotifications();
            ISN_UIApplication.ApplicationDelegate.DidRegisterForRemoteNotifications.AddListener((result) => {
                if (result.IsSucceeded)
                {
                    var token = result.DeviceTokenUTF8;
                    Debug.Log("ANS token string:" + token);
                }
                else
                {
                    Debug.Log("Error: " + result.Error.Message);
                }
            });
        }
コード例 #5
0
        public void NoSoundToTrigger()
        {
            var content = new ISN_UNNotificationContent();

            content.Title = "Hello";
            content.Body  = "Hello_message_body";

            var request = new ISN_UNNotificationRequest("FiveSecond", content, null);

            // Schedule the notification.
            ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
            });
        }
コード例 #6
0
        public void NotificationInterval()
        {
            var content = new ISN_UNNotificationContent();

            content.Title = "Hello";
            content.Body  = "Hello_message_body";
            content.Sound = ISN_UNNotificationSound.DefaultSound;


            // Deliver the notification in five seconds.
            var trigger = new ISN_UNTimeIntervalNotificationTrigger(5, repeats: false);

            var request = new ISN_UNNotificationRequest("FiveSecond", content, trigger);


            // Schedule the notification.
            ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
            });
        }
コード例 #7
0
    private void ScheduleIOSNotification()
    {
        var content = new ISN_UNNotificationContent();

        content.Title    = m_iOSNotificationTitle.text;
        content.Body     = m_iOSNotificationBody.text;
        content.Subtitle = m_iOSNotificationSubtitle.text;
        content.Badge    = Convert.ToInt32(m_iOSNotificationBadge.text);

        var seconds = 5;
        var repeats = false;
        var trigger = new ISN_UNTimeIntervalNotificationTrigger(seconds, repeats);

        var identifier = "TestAlarm";
        var request    = new ISN_UNNotificationRequest(identifier, content, trigger);

        ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
            Debug.Log("iOS AddNotificationRequest: " + result.IsSucceeded);
        });
    }
コード例 #8
0
        public override void Test()
        {
            ISN_UNUserNotificationCenterDelegate.WillPresentNotification.AddListener((ISN_UNNotification notification) => {
                ValidateRequest(notification.Request);
                ISN_UNUserNotificationCenterDelegate.ClearLastReceivedResponse();
            });

            ISN_UNUserNotificationCenterDelegate.DidReceiveNotificationResponse.AddListener((ISN_UNNotificationResponse notification) => {
                ValidateRequest(notification.Notification.Request);
                ISN_UNUserNotificationCenterDelegate.ClearLastReceivedResponse();
            });


            var userInfo = new ISN_UNNotificationContent();

            userInfo.Title = "Info Test";

            var content = new ISN_UNNotificationContent();

            content.Title = "Wake up!";
            content.Body  = "Rise and shine! It's morning time!";

            content.SetUserInfo(userInfo);


            int  seconds = 2;
            bool repeats = false;
            var  trigger = new ISN_UNTimeIntervalNotificationTrigger(seconds, repeats);

            // Create the request object.
            string identifier = "IntervalAlarm";

            m_request = new ISN_UNNotificationRequest(identifier, content, trigger);

            ISN_UNUserNotificationCenter.AddNotificationRequest(m_request, (result) => {
                if (result.IsFailed)
                {
                    SetAPIResult(result);
                }
            });
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        private void ValidateRequest(ISN_UNNotificationRequest presentdeRequest)
        {
            bool valid = true;

            if (!presentdeRequest.Content.Body.Equals(m_request.Content.Body))
            {
                valid = false;
            }

            if (!presentdeRequest.Content.Title.Equals(m_request.Content.Title))
            {
                valid = false;
            }

            if (!presentdeRequest.Content.Subtitle.Equals(m_request.Content.Subtitle))
            {
                valid = false;
            }


            var userInfoJson1 = presentdeRequest.Content.GetUserInfo <ISN_UNNotificationContent>();

            if (!userInfoJson1.Title.Equals("Info Test"))
            {
                valid = false;
            }

            if (valid)
            {
                SetResult(SA_TestResult.OK);
            }
            else
            {
                SetResult(SA_TestResult.WithError("Request Validation failede"));
            }
        }
コード例 #11
0
        public void NotificationCalendar()
        {
            var content = new ISN_UNNotificationContent();

            content.Title = "Hello";
            content.Body  = "Hello_message_body";
            content.Sound = ISN_UNNotificationSound.DefaultSound;



            var date = new ISN_NSDateComponents();

            date.Hour   = 8;
            date.Minute = 30;

            var trigger = new ISN_UNCalendarNotificationTrigger(date, repeats: true);
            var request = new ISN_UNNotificationRequest("FiveSecond", content, trigger);


            // Schedule the notification.
            ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
            });
        }
コード例 #12
0
 public void AddNotificationRequest(ISN_UNNotificationRequest request, Action <SA_Result> callback)
 {
 }
コード例 #13
0
        void OnGUI()
        {
            UpdateToStartPos();

            GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "User Notifications", style);
            StartY += YLableStep;



            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Notification Setting"))
            {
                ISN_UNUserNotificationCenter.GetNotificationSettings((setting) => {
                    Debug.Log("Got the settings");
                    Debug.Log(setting.AuthorizationStatus.ToString());
                });
            }



            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Stop Recording"))
            {
                int options = ISN_UNAuthorizationOptions.Alert | ISN_UNAuthorizationOptions.Sound;
                ISN_UNUserNotificationCenter.RequestAuthorization(options, (result) => {
                    Debug.Log("RequestAuthorization: " + result.IsSucceeded);
                });
            }



            StartX  = XStartPos;
            StartY += YButtonStep;
            StartY += YLableStep;

            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Add Notification Interval"))
            {
                var content = new ISN_UNNotificationContent();
                content.Title = "Hello";
                content.Body  = "Hello_message_body";
                content.Sound = ISN_UNNotificationSound.DefaultSound;


                // Deliver the notification in five seconds.
                var trigger = new ISN_UNTimeIntervalNotificationTrigger(5, repeats: false);

                var request = new ISN_UNNotificationRequest("FiveSecond", content, trigger);


                // Schedule the notification.
                ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                    Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Add Notification Calendar"))
            {
                var content = new ISN_UNNotificationContent();
                content.Title = "Hello";
                content.Body  = "Hello_message_body";
                content.Sound = ISN_UNNotificationSound.DefaultSound;



                var date = new ISN_NSDateComponents();
                date.Hour   = 8;
                date.Minute = 30;

                var trigger = new ISN_UNCalendarNotificationTrigger(date, repeats: true);
                var request = new ISN_UNNotificationRequest("FiveSecond", content, trigger);


                // Schedule the notification.
                ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                    Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Add Notification Location"))
            {
                var content = new ISN_UNNotificationContent();
                content.Title = "Hello";
                content.Body  = "Hello_message_body";
                content.Sound = ISN_UNNotificationSound.DefaultSound;


                var center = new ISN_CLLocationCoordinate2D(37.335400f, -122.009201f);
                var region = new ISN_CLCircularRegion(center, 2000f, "Headquarters");

                region.NotifyOnEntry = true;
                region.NotifyOnExit  = false;

                // Deliver the notification in five seconds.
                var trigger = new ISN_UNLocationNotificationTrigger(region, repeats: false);

                var request = new ISN_UNNotificationRequest("FiveSecond", content, trigger);


                // Schedule the notification.
                ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                    Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
                });
            }



            StartX  = XStartPos;
            StartY += YButtonStep;
            StartY += YLableStep;

            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "No Sound, No triggrt"))
            {
                var content = new ISN_UNNotificationContent();
                content.Title = "Hello";
                content.Body  = "Hello_message_body";

                var request = new ISN_UNNotificationRequest("FiveSecond", content, null);


                // Schedule the notification.
                ISN_UNUserNotificationCenter.AddNotificationRequest(request, (result) => {
                    Debug.Log("AddNotificationRequest: " + result.IsSucceeded);
                });
            }
        }