Beispiel #1
0
//Sets location trigger
    public void SetLocationTrigger()
    {
        Input.location.Start();

        var locationTrigger = new iOSNotificationLocationTrigger()
        {
            Center        = new Vector2(37.7749f, 122.4194f),
            Radius        = 5500f,
            NotifyOnEntry = true,
            NotifyOnExit  = true,
        };


        iOSNotification n = new iOSNotification()
        {
            Title                        = "Location notification ",
            Body                         = "Center: " + locationTrigger.Center.ToString() + "  Radius: " + locationTrigger.Radius.ToString(),
            Subtitle                     = "I'ma subtitle!",
            ShowInForeground             = true,
            ForegroundPresentationOption = PresentationOption.Sound | PresentationOption.Alert | PresentationOption.Badge,
            CategoryIdentifier           = "CategeoryX",
            ThreadIdentifier             = "locationNotifications",
            Trigger                      = locationTrigger,
            Badge                        = 13,
        };

        iOSNotificationCenter.ScheduleNotification(n);

        Debug.Log("Rescheduled remote notifications with id: " + n.Identifier);
    }
Beispiel #2
0
    private void Start()
    {
        iOSNotificationTimeIntervalTrigger timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, 0, 10),
            Repeats      = false,
        };

        iOSNotificationCalendarTrigger calendarTrigger = new iOSNotificationCalendarTrigger()
        {
            // Year = 2019,
            // Month = 8,
            //Day = 30,
            Hour   = 12,
            Minute = 0,
            // Second = 0
            Repeats = false
        };

        iOSNotificationLocationTrigger locationTrigger = new iOSNotificationLocationTrigger()
        {
            Center        = new Vector2(2.294498f, 48.858263f),
            Radius        = 250f,
            NotifyOnEntry = true,
            NotifyOnExit  = false,
        };

        iOSNotification notification = new iOSNotification()
        {
            Identifier                   = "test_notification",
            Title                        = "Test Notification!",
            Subtitle                     = "A Unity Royale Test Notification",
            Body                         = "This is a test notification!",
            ShowInForeground             = true,
            ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
            CategoryIdentifier           = "category_a",
            ThreadIdentifier             = "thread1",
            Trigger                      = timeTrigger,
        };

        iOSNotificationCenter.ScheduleNotification(notification);

        iOSNotificationCenter.OnRemoteNotificationReceived += recievedNotification =>
        {
            Debug.Log("Recieved notification " + notification.Identifier + "!");
        };


        iOSNotification notificationIntentData = iOSNotificationCenter.GetLastRespondedNotification();

        if (notificationIntentData != null)
        {
            Debug.Log("App was opened with notification!");
        }
    }