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);
                }
            });
        }
예제 #2
0
        /// <summary>
        /// Will send an application to background.
        /// The method can be used to emulate pressing a Home button.
        /// </summary>
        public static void SendToBackground()
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                AN_MainActivity.Instance.MoveTaskToBack(true);
                break;

            case RuntimePlatform.IPhonePlayer:
                ISN_UIApplication.Suspend();
                break;
            }
        }
        public void RequestUserNotificationPermission()
        {
            int options = ISN_UNAuthorizationOptions.Alert | ISN_UNAuthorizationOptions.Sound;

            ISN_UNUserNotificationCenter.RequestAuthorization(options, (result) => {
                Debug.Log("RequestAuthorization: " + result.IsSucceeded);
            });

            ISN_UIApplication.RegisterForRemoteNotifications();
            ISN_UIApplication.ApplicationDelegate.DidRegisterForRemoteNotifications.AddListener((result) => {
                if (result.IsSucceeded)
                {
                    Debug.Log(result.DeviceTokenUTF8);
                }
            });
        }
        public override void Test()
        {
            ISN_UIApplication.RegisterForRemoteNotifications();
            ISN_UIApplication.ApplicationDelegate.DidRegisterForRemoteNotifications.AddListener((result) => {
                if (result.IsSucceeded)
                {
                    var token = result.DeviceTokenUTF8;
                    if (string.IsNullOrEmpty(token))
                    {
                        SetResult(SA_TestResult.WithError("Token is empty"));
                        return;
                    }
                    ISN_Logger.Log("ANS token string:" + token);
                }
                else
                {
                    ISN_Logger.Log("Error: " + result.Error.Message);
                }

                SetAPIResult(result);
            });
        }