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); }); }
/// <summary> /// Creates and returns a location trigger for the specified region. /// </summary> /// <param name="region"> /// The region to use for the trigger. /// The trigger fires when the user’s device enters or leaves the region. /// Use the region object to specify whether to deliver notifications on entry, on exit, or both. /// </param> /// <param name="repeats"> /// Specify <c>false</c> to unschedule the notification after the trigger fires. /// Specify <c>true</c> if you want the notification to be rescheduled after it fires. /// </param> public ISN_UNLocationNotificationTrigger(ISN_CLCircularRegion region, bool repeats) { m_region = region; m_repeats = repeats; m_type = ISN_UNNotificationTriggerType.Location; }
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); }); } }