//-------------------------------------- // GET/SET //-------------------------------------- //-------------------------------------- // EVENTS //-------------------------------------- public void onPopUpCallBack(string buttonIndex) { int index = System.Convert.ToInt16(buttonIndex); switch (index) { case 0: IOSNativeUtility.RedirectToAppStoreRatingPage(); OnComplete(IOSDialogResult.RATED); dispatch(BaseEvent.COMPLETE, IOSDialogResult.RATED); break; case 1: OnComplete(IOSDialogResult.REMIND); dispatch(BaseEvent.COMPLETE, IOSDialogResult.REMIND); break; case 2: OnComplete(IOSDialogResult.DECLINED); dispatch(BaseEvent.COMPLETE, IOSDialogResult.DECLINED); break; } Destroy(gameObject); }
protected override void GameSetup() { base.GameSetup(); #if UNITY_IPHONE SA.IOSNative.Core.AppController.OnApplicationDidBecomeActive += OnApplicationDidBecomeActive; IOSNativeUtility.SetApplicationBagesNumber(0); #endif CheckNotificationsPermission(); }
public static void HidePreloader() { if (TimeOutTask != null) { TimeOutTask.Cancel(); TimeOutTask = null; } if (Application.platform == RuntimePlatform.Android) { AndroidNativeUtility.HidePreloader(); } if (Application.platform == RuntimePlatform.IPhonePlayer) { IOSNativeUtility.HidePreloader(); } }
public static void ShowPreloader() { if (TimeOutTask != null) { return; } TimeOutTask = MultiplayerPreloaderTimeoutTask.Create(); if (Application.platform == RuntimePlatform.Android) { AndroidNativeUtility.ShowPreloader("", ""); } if (Application.platform == RuntimePlatform.IPhonePlayer) { IOSNativeUtility.ShowPreloader(); } }
void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "System Utils", style); //SA.IOSNative. StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Check if FB App exists")) { bool result = SA.IOSNative.System.SharedApplication.CheckUrl("fb://"); if (result) { IOSMessage.Create("Success", "Facebook App is installed on current device"); } else { IOSMessage.Create("ERROR", "Facebook App is not installed on current device"); } } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Open FB Profile")) { SA.IOSNative.System.SharedApplication.OpenUrl("fb://profile"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Open App Store")) { SA.IOSNative.System.SharedApplication.OpenUrl("itms-apps://"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get IFA")) { IOSMessage.Create("Identifier Loaded", ISN_Device.CurrentDevice.AdvertisingIdentifier); } StartX = XStartPos; StartY += YButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Set App Bages Count")) { IOSNativeUtility.SetApplicationBagesNumber(10); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Clear Application Bages")) { IOSNativeUtility.SetApplicationBagesNumber(0); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Device Info")) { ShowDevoceInfo(); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Pick Contacts UI")) { SA.IOSNative.Contacts.ContactStore.Instance.ShowContactsPickerUI((result) => { if (result.IsSucceeded) { Debug.Log("Picked " + result.Contacts.Count + " contacts"); IOSMessage.Create("Success", "Picked " + result.Contacts.Count + " contacts"); foreach (var contact in result.Contacts) { Debug.Log("contact.GivenName: " + contact.GivenName); if (contact.PhoneNumbers.Count > 0) { Debug.Log("contact.PhoneNumber: " + contact.PhoneNumbers[0].Digits); } if (contact.Emails.Count > 0) { Debug.Log("contact.Email: " + contact.Emails[0]); } } } else { IOSMessage.Create("Error", result.Error.Code + " / " + result.Error.Message); } }); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Load Contacts")) { SA.IOSNative.Contacts.ContactStore.Instance.RetrievePhoneContacts((result) => { if (result.IsSucceeded) { Debug.Log("Loaded " + result.Contacts.Count + " contacts"); IOSMessage.Create("Success", "Loaded " + result.Contacts.Count + " contacts"); foreach (var contact in result.Contacts) { if (contact.PhoneNumbers.Count > 0) { Debug.Log(contact.GivenName + " / " + contact.PhoneNumbers[0].Digits); } } } else { IOSMessage.Create("Error", result.Error.Code + " / " + result.Error.Message); } }); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Date Time Picker", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Time")) { IOSDateTimePicker.Instance.Show(IOSDateTimePickerMode.Time); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date")) { IOSDateTimePicker.Instance.Show(IOSDateTimePickerMode.Date); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date And Time")) { IOSDateTimePicker.Instance.Show(IOSDateTimePickerMode.DateAndTime); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Countdown Timer")) { IOSDateTimePicker.Instance.Show(IOSDateTimePickerMode.CountdownTimer); } StartX = XStartPos; StartY += YButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Set Date Without UI")) { IOSDateTimePicker.Instance.Show(IOSDateTimePickerMode.Date, time); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Video", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Player Streamed video")) { IOSVideoManager.Instance.PlayStreamingVideo("https://dl.dropboxusercontent.com/u/83133800/Important/Doosan/GT2100-Video.mov"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Open YouTube Video")) { IOSVideoManager.Instance.OpenYouTubeVideo("xzCEdSKMkdU"); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Camera Roll", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth + 10, buttonHeight), "Save Screenshot To Camera Roll")) { IOSCamera.OnImageSaved += OnImageSaved; IOSCamera.Instance.SaveScreenshotToCameraRoll(); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Save Texture To Camera Roll")) { IOSCamera.OnImageSaved += OnImageSaved; IOSCamera.Instance.SaveTextureToCameraRoll(hello_texture); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Image From Camera")) { IOSCamera.OnImagePicked += OnImage; IOSCamera.Instance.PickImage(ISN_ImageSource.Camera); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Image From Album")) { IOSCamera.OnImagePicked += OnImage; IOSCamera.Instance.PickImage(ISN_ImageSource.Album); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Load Multiple Images")) { ISN_FilePicker.MediaPickFinished += delegate(ISN_FilePickerResult res) { Debug.Log("Picked " + res.PickedImages.Count + " images"); if (res.PickedImages.Count == 0) { return; } //destroying old texture Destroy(drawTexture); //applaying new texture drawTexture = res.PickedImages[0]; }; ISN_FilePicker.Instance.PickFromCameraRoll(); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "PickedImage", style); StartY += YLableStep; if (drawTexture != null) { GUI.DrawTexture(new Rect(StartX, StartY, buttonWidth, buttonWidth), drawTexture); } }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- void OnGUI() { UpdateToStartPos(); UnityEngine.GUI.Label(new UnityEngine.Rect(StartX, StartY, UnityEngine.Screen.width, 40), "Local and Push Notifications", style); StartY += YLableStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule Notification Silent")) { IOSNotificationController.OnNotificationScheduleResult += OnNotificationScheduleResult; ISN_LocalNotification notification = new ISN_LocalNotification(DateTime.Now.AddSeconds(5), "Your Notification Text No Sound", false); notification.SetData("some_test_data"); notification.Schedule(); lastNotificationId = notification.Id; } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule Notification")) { IOSNotificationController.OnNotificationScheduleResult += OnNotificationScheduleResult; ISN_LocalNotification notification = new ISN_LocalNotification(DateTime.Now.AddSeconds(5), "Your Notification Text", true); notification.SetData("some_test_data"); notification.SetSoundName("purchase_ok.wav"); notification.SetBadgesNumber(1); notification.Schedule(); lastNotificationId = notification.Id; } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cancel All Notifications")) { IOSNotificationController.instance.CancelAllLocalNotifications(); IOSNativeUtility.SetApplicationBagesNumber(0); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cansel Last Notification")) { IOSNotificationController.instance.CancelLocalNotificationById(lastNotificationId); } StartX = XStartPos; StartY += YButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Reg Device For Push Notif. ")) { #if UNITY_IPHONE #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 IOSNotificationController.Instance.RegisterForRemoteNotifications(RemoteNotificationType.Alert | RemoteNotificationType.Badge | RemoteNotificationType.Sound); IOSNotificationController.OnDeviceTokenReceived += OnDeviceTokenReceived; #else IOSNotificationController.Instance.RegisterForRemoteNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); IOSNotificationController.OnDeviceTokenReceived += OnDeviceTokenReceived; #endif #endif } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Game Kit Notification")) { IOSNotificationController.instance.ShowGmaeKitNotification("Title", "Message"); } }
void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Using URL Scheme", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Check if FB App exists")) { IOSSharedApplication.instance.CheckUrl("fb://"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Open FB Profile")) { IOSSharedApplication.instance.OpenUrl("fb://profile"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Open App Store")) { IOSSharedApplication.instance.OpenUrl("itms-apps://"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get IFA")) { IOSSharedApplication.OnAdvertisingIdentifierLoadedAction += OnAdvertisingIdentifierLoadedAction; IOSSharedApplication.instance.GetAdvertisingIdentifier(); } StartX = XStartPos; StartY += YButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Set App Bages Count")) { IOSNativeUtility.SetApplicationBagesNumber(10); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Clear Application Bages")) { IOSNativeUtility.SetApplicationBagesNumber(0); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Date Time Picker", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Time")) { IOSDateTimePicker.instance.Show(IOSDateTimePickerMode.Time); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date")) { IOSDateTimePicker.instance.Show(IOSDateTimePickerMode.Date); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date And Time")) { IOSDateTimePicker.instance.Show(IOSDateTimePickerMode.DateAndTime); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Countdown Timer")) { IOSDateTimePicker.instance.Show(IOSDateTimePickerMode.CountdownTimer); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Video", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Player Streamed video")) { IOSVideoManager.instance.PlayStreamingVideo("https://dl.dropboxusercontent.com/u/83133800/Important/Doosan/GT2100-Video.mov"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Open YouTube Video")) { IOSVideoManager.instance.OpenYouTubeVideo("xzCEdSKMkdU"); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Camera Roll", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth + 10, buttonHeight), "Save Screenshot To Camera Roll")) { IOSCamera.OnImageSaved += OnImageSaved; IOSCamera.Instance.SaveScreenshotToCameraRoll(); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Save Texture To Camera Roll")) { IOSCamera.OnImageSaved += OnImageSaved; IOSCamera.Instance.SaveTextureToCameraRoll(hello_texture); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Image From Camera")) { IOSCamera.OnImagePicked += OnImage; IOSCamera.Instance.GetImageFromCamera(); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Image From Album")) { IOSCamera.OnImagePicked += OnImage; IOSCamera.Instance.GetImageFromAlbum(); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "PickedImage", style); StartY += YLableStep; if (drawTexture != null) { GUI.DrawTexture(new Rect(StartX, StartY, buttonWidth, buttonWidth), drawTexture); } }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- void OnGUI() { UpdateToStartPos(); UnityEngine.GUI.Label(new UnityEngine.Rect(StartX, StartY, UnityEngine.Screen.width, 40), "Local and Push Notifications", style); StartY += YLableStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Request Permissions")) { ISN_LocalNotificationsController.Instance.RequestNotificationPermissions(); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Print Notification Settings")) { CheckNotificationSettings(); } StartY += YButtonStep; StartX = XStartPos; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule Notification Silent")) { ISN_LocalNotificationsController.OnNotificationScheduleResult += OnNotificationScheduleResult; ISN_LocalNotification notification = new ISN_LocalNotification(DateTime.Now.AddSeconds(5), "Your Notification Text No Sound", false); notification.SetData("some_test_data"); notification.Schedule(); lastNotificationId = notification.Id; } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule Notification")) { ISN_LocalNotificationsController.OnNotificationScheduleResult += OnNotificationScheduleResult; ISN_LocalNotification notification = new ISN_LocalNotification(DateTime.Now.AddSeconds(5), "Your Notification Text", true); notification.SetData("some_test_data"); notification.SetSoundName("purchase_ok.wav"); notification.SetBadgesNumber(1); notification.Schedule(); lastNotificationId = notification.Id; } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cancel All Notifications")) { ISN_LocalNotificationsController.Instance.CancelAllLocalNotifications(); IOSNativeUtility.SetApplicationBagesNumber(0); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cansel Last Notification")) { ISN_LocalNotificationsController.Instance.CancelLocalNotificationById(lastNotificationId); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; UnityEngine.GUI.Label(new UnityEngine.Rect(StartX, StartY, UnityEngine.Screen.width, 40), "Local and Push Notifications", style); StartY += YLableStep; StartX = XStartPos; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Reg Device For Push Notif. ")) { //ISN_RemotelNotifications.Instance.RegisterForRemoteNotifications (0); ISN_RemoteNotificationsController.Instance.RegisterForRemoteNotifications((ISN_RemoteNotificationsRegistrationResult res) => { Debug.Log("ISN_RemoteNotificationsRegistrationResult: " + res.IsSucceeded); if (!res.IsSucceeded) { Debug.Log(res.Error.Code + " / " + res.Error.Message); } else { Debug.Log(res.Token.DeviceId); } }); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Game Kit Notification")) { ISN_LocalNotificationsController.Instance.ShowGmaeKitNotification("Title", "Message"); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; UnityEngine.GUI.Label(new UnityEngine.Rect(StartX, StartY, UnityEngine.Screen.width, 40), "User Notifications", style); StartY += YLableStep; StartX = XStartPos; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Reg Device For User Notif. ")) { SA.IOSNative.UserNotifications.NotificationCenter.RequestPermissions((result) => { ISN_Logger.Log("RequestPermissions callback" + result.ToString()); }); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule for 5 sec")) { var content = new SA.IOSNative.UserNotifications.NotificationContent(); content.Title = "Title_"; content.Subtitle = "Subtitle_"; content.Body = "Body_"; content.Badge = 1; content.Sound = "beep.mp3"; content.UserInfo ["404"] = "test User Info"; var trigger = new SA.IOSNative.UserNotifications.TimeIntervalTrigger(5); var request = new SA.IOSNative.UserNotifications.NotificationRequest("some0id0", content, trigger); ISN_Logger.Log("request Schedule for 5 sec"); SA.IOSNative.UserNotifications.NotificationCenter.AddNotificationRequest(request, (result) => { ISN_Logger.Log("request callback"); ISN_Logger.Log(result.ToString()); }); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule by Calendar - Date Components")) { var content = new SA.IOSNative.UserNotifications.NotificationContent(); content.Title = "Calendar - Date Components"; content.Subtitle = "Subtitle_"; content.Body = "Body_"; content.Badge = 1; content.UserInfo ["404"] = "test User Info"; var dateComponents = new SA.IOSNative.UserNotifications.DateComponents() { Second = 32, // You can use any of this fields or their combination; In this example, trigger will fire every 32nd second // public int? Year; // public int? Month; // public int? Day; // public int? Hour; // public int? Minute; // public int? Second; // public int? Weekday; (1 - Sunday, 7 - Saturday) // public int? Quarter; }; var trigger = new SA.IOSNative.UserNotifications.CalendarTrigger(dateComponents); trigger.SetRepeat(true); var request = new SA.IOSNative.UserNotifications.NotificationRequest("some0id1", content, trigger); SA.IOSNative.UserNotifications.NotificationCenter.AddNotificationRequest(request, (result) => { ISN_Logger.Log("request callback"); ISN_Logger.Log(result.ToString()); }); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule by Calendar - Date")) { var content = new SA.IOSNative.UserNotifications.NotificationContent(); content.Title = "Calendar - Date"; content.Subtitle = "Subtitle_"; content.Body = "Body_"; content.Badge = 1; content.UserInfo ["404"] = 1; var dateComponents = new SA.IOSNative.UserNotifications.DateComponents() { Second = 32, Year = 2017, Month = 6, Day = 6, Hour = 13, Minute = 01 // You can use any of this fields or their combination; In this example, trigger will fire every Friday, every 32nd second // public int? Year; // public int? Month; // public int? Day; // public int? Hour; // public int? Minute; // public int? Second; // public int? Weekday; (1 - Sunday, 7 - Saturday) // public int? Quarter; }; var trigger = new SA.IOSNative.UserNotifications.CalendarTrigger(dateComponents); var request = new SA.IOSNative.UserNotifications.NotificationRequest("some0id2", content, trigger); SA.IOSNative.UserNotifications.NotificationCenter.AddNotificationRequest(request, (result) => { ISN_Logger.Log("request callback"); ISN_Logger.Log(result.ToString()); }); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cancel All User Notifications")) { SA.IOSNative.UserNotifications.NotificationCenter.CancelAllNotifications(); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cancel some0id2")) { SA.IOSNative.UserNotifications.NotificationCenter.CancelUserNotificationById("some0id2"); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Pending UserNotifications")) { SA.IOSNative.UserNotifications.NotificationCenter.GetPendingNotificationRequests(requests => { for (int i = 0; i < requests.Count; i++) { ISN_Logger.Log(requests[i].Content.Title); } }); } }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Native Pop-ups", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Rate Pop-up with events")) { IOSRateUsPopUp rate = IOSRateUsPopUp.Create("Like this game?", "Please rate to support future updates!"); rate.OnComplete += onRatePopUpClose; } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Dialog Pop-up")) { IOSDialog dialog = IOSDialog.Create("Dialog Title", "Dialog message"); dialog.OnComplete += onDialogClose; } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Message Pop-up")) { IOSMessage msg = IOSMessage.Create("Message Title", "Message body"); msg.OnComplete += onMessageClose; } StartX = XStartPos; StartY += YButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Dismissed Pop-up")) { Invoke("dismissAlert", 2f); IOSMessage.Create("Hello", "I will die in 2 sec"); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Open App Store")) { IOSNativeUtility.RedirectToAppStoreRatingPage(); } StartX = XStartPos; StartY += YButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Preloader ")) { IOSNativeUtility.ShowPreloader(); Invoke("HidePreloader", 3f); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Hide Preloader")) { HidePreloader(); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Locale")) { IOSNativeUtility.OnLocaleLoaded += GetLocale; IOSNativeUtility.Instance.GetLocale(); } }
//-------------------------------------- // GET/SET //-------------------------------------- //-------------------------------------- // EVENTS //-------------------------------------- private void HidePreloader() { IOSNativeUtility.HidePreloader(); }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- void OnGUI() { UpdateToStartPos(); UnityEngine.GUI.Label(new UnityEngine.Rect(StartX, StartY, UnityEngine.Screen.width, 40), "Local and Push Notifications", style); StartY += YLableStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Request Permissions")) { ISN_LocalNotificationsController.Instance.RequestNotificationPermissions(); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Print Notification Settings")) { CheckNotificationSettings(); } StartY += YButtonStep; StartX = XStartPos; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule Notification Silent")) { ISN_LocalNotificationsController.OnNotificationScheduleResult += OnNotificationScheduleResult; ISN_LocalNotification notification = new ISN_LocalNotification(DateTime.Now.AddSeconds(5), "Your Notification Text No Sound", false); notification.SetData("some_test_data"); notification.Schedule(); lastNotificationId = notification.Id; } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Schedule Notification")) { ISN_LocalNotificationsController.OnNotificationScheduleResult += OnNotificationScheduleResult; ISN_LocalNotification notification = new ISN_LocalNotification(DateTime.Now.AddSeconds(5), "Your Notification Text", true); notification.SetData("some_test_data"); notification.SetSoundName("purchase_ok.wav"); notification.SetBadgesNumber(1); notification.Schedule(); lastNotificationId = notification.Id; } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cancel All Notifications")) { ISN_LocalNotificationsController.Instance.CancelAllLocalNotifications(); IOSNativeUtility.SetApplicationBagesNumber(0); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Cansel Last Notification")) { ISN_LocalNotificationsController.Instance.CancelLocalNotificationById(lastNotificationId); } StartX = XStartPos; StartY += YButtonStep; StartY += YLableStep; UnityEngine.GUI.Label(new UnityEngine.Rect(StartX, StartY, UnityEngine.Screen.width, 40), "Local and Push Notifications", style); StartY += YLableStep; StartX = XStartPos; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Reg Device For Push Notif. ")) { //ISN_RemotelNotifications.Instance.RegisterForRemoteNotifications (0); ISN_RemoteNotificationsController.Instance.RegisterForRemoteNotifications((ISN_RemoteNotificationsRegistrationResult res) => { Debug.Log("ISN_RemoteNotificationsRegistrationResult: " + res.IsSucceeded); if (!res.IsSucceeded) { Debug.Log(res.Error.Code + " / " + res.Error.Message); } else { Debug.Log(res.Token.DeviceId); } }); } StartX += XButtonStep; if (UnityEngine.GUI.Button(new UnityEngine.Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Game Kit Notification")) { ISN_LocalNotificationsController.Instance.ShowGmaeKitNotification("Title", "Message"); } }
// void Start() // { // review_coins = PlayerPrefs.GetString("Review",review_coins); // reward_panel = PlayerPrefs.GetString("reward panel",reward_panel); // // if(reward_panel == "not active" || review_coins == "not reviewed") // { // Debug.Log("player didnt write review yet"); // } // else if (reward_panel == "was activate" || review_coins == "not reviewed") // { // ActivateRewardPanel(); // } // else if (reward_panel == "was activate" || review_coins == "is reviewed") // { // Debug.Log("player was awarded already"); // } // } public void RateMeOnAppStore() { IOSNativeUtility.RedirectToAppStoreRatingPage();; }
private void OnApplicationDidBecomeActive() { IOSNativeUtility.SetApplicationBagesNumber(0); }