Beispiel #1
0
        /// <summary>
        /// Schedule customizable notification.
        /// </summary>
        public static int SendCustom(NotificationParams notificationParams)
        {
            #if UNITY_EDITOR
            Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!");
            #elif UNITY_ANDROID
            var p              = notificationParams;
            var delay          = (long)p.Delay.TotalMilliseconds;
            var repeatInterval = p.Repeat ? (long)p.RepeatInterval.TotalMilliseconds : 0;
            var vibration      = string.Join(",", p.Vibration.Select(i => i.ToString()).ToArray());

            new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, p.GroupName ?? "", p.GroupSummary ?? "", p.ChannelId, p.ChannelName, delay, Convert.ToInt32(p.Repeat), repeatInterval, p.Title, p.Message, p.Ticker, Convert.ToInt32(p.Multiline),
                                                           Convert.ToInt32(p.Sound), p.CustomSound ?? "", Convert.ToInt32(p.Vibrate), vibration, Convert.ToInt32(p.Light), p.LightOnMs, p.LightOffMs, ColotToInt(p.LightColor), p.LargeIcon ?? "", GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), (int)p.ExecuteMode, p.CallbackData, MainActivityClassName);

            NotificationIdHandler.AddScheduledNotificaion(p.Id);
            #elif UNITY_IPHONE
            var notification = new UnityEngine.iOS.LocalNotification
            {
                hasAction = false,
                alertBody = notificationParams.Message,
                fireDate  = DateTime.Now.Add(notificationParams.Delay)
            };

            UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(notification);
            #endif

            return(notificationParams.Id);
        }
Beispiel #2
0
        public static int SendCustom(NotificationParams notificationParams)
        {
            NotificationParams notificationParam = notificationParams;
            long   totalMilliseconds             = (long)notificationParam.Delay.TotalMilliseconds;
            long   num = (!notificationParam.Repeat ? (long)0 : (long)notificationParam.RepeatInterval.TotalMilliseconds);
            string str = string.Join(",", (
                                         from i in (IEnumerable <int>)notificationParam.Vibration
                                         select i.ToString()).ToArray <string>());

            (new AndroidJavaClass("com.hippogames.simpleandroidnotifications.Controller")).CallStatic("SetNotification", new object[] { notificationParam.Id, notificationParam.GroupName ?? string.Empty, notificationParam.GroupSummary ?? string.Empty, notificationParam.ChannelId, notificationParam.ChannelName, totalMilliseconds, Convert.ToInt32(notificationParam.Repeat), num, notificationParam.Title, notificationParam.Message, notificationParam.Ticker, Convert.ToInt32(notificationParam.Multiline), Convert.ToInt32(notificationParam.Sound), notificationParam.CustomSound ?? string.Empty, Convert.ToInt32(notificationParam.Vibrate), str, Convert.ToInt32(notificationParam.Light), notificationParam.LightOnMs, notificationParam.LightOffMs, NotificationManager.ColotToInt(notificationParam.LightColor), notificationParam.LargeIcon ?? string.Empty, NotificationManager.GetSmallIconName(notificationParam.SmallIcon), NotificationManager.ColotToInt(notificationParam.SmallIconColor), (int)notificationParam.ExecuteMode, notificationParam.CallbackData, "com.blizzard.wowcompanion.CompanionNativeActivity" });
            NotificationIdHandler.AddScheduledNotificaion(notificationParam.Id);
            return(notificationParams.Id);
        }
Beispiel #3
0
        /// <summary>
        /// Schedule customizable notification.
        /// </summary>
        public static int SendCustom(NotificationParams notificationParams)
        {
            #if UNITY_ANDROID && !UNITY_EDITOR
            var p              = notificationParams;
            var delay          = (long)p.Delay.TotalMilliseconds;
            var repeatInterval = p.Repeat ? (long)p.RepeatInterval.TotalMilliseconds : 0;
            var vibration      = string.Join(",", p.Vibration.Select(i => i.ToString()).ToArray());

            new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, delay, p.Repeat ? 1 : 0, repeatInterval, p.Title, p.Message, p.Ticker,
                                                           p.Sound ? 1 : 0, p.Vibrate ? 1 : 0, vibration, p.Light ? 1 : 0, p.LightOnMs, p.LightOffMs, ColotToInt(p.LightColor), p.LargeIcon, GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), (int)p.ExecuteMode, p.CallbackData, MainActivityClassName);

            NotificationIdHandler.AddScheduledNotificaion(p.Id);
            #else
            Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!");
            #endif

            return(notificationParams.Id);
        }
        public static int SendCustom(NotificationParams notificationParams)
        {
            long   num  = (long)notificationParams.Delay.TotalMilliseconds;
            long   num2 = (!notificationParams.Repeat) ? 0L : ((long)notificationParams.RepeatInterval.TotalMilliseconds);
            string text = string.Join(",", (from i in notificationParams.Vibration
                                            select i.ToString()).ToArray <string>());

            new AndroidJavaClass("com.hippogames.simpleandroidnotifications.Controller").CallStatic("SetNotification", new object[]
            {
                notificationParams.Id,
                notificationParams.GroupName ?? string.Empty,
                notificationParams.GroupSummary ?? string.Empty,
                notificationParams.ChannelId,
                notificationParams.ChannelName,
                num,
                Convert.ToInt32(notificationParams.Repeat),
                num2,
                notificationParams.Title,
                notificationParams.Message,
                notificationParams.Ticker,
                Convert.ToInt32(notificationParams.Multiline),
                Convert.ToInt32(notificationParams.Sound),
                notificationParams.CustomSound ?? string.Empty,
                Convert.ToInt32(notificationParams.Vibrate),
                text,
                Convert.ToInt32(notificationParams.Light),
                notificationParams.LightOnMs,
                notificationParams.LightOffMs,
                NotificationManager.ColotToInt(notificationParams.LightColor),
                notificationParams.LargeIcon ?? string.Empty,
                NotificationManager.GetSmallIconName(notificationParams.SmallIcon),
                NotificationManager.ColotToInt(notificationParams.SmallIconColor),
                (int)notificationParams.ExecuteMode,
                (int)notificationParams.Importance,
                notificationParams.CallbackData,
                "com.google.firebase.MessagingUnityPlayerActivity"
            });
            NotificationIdHandler.AddScheduledNotificaion(notificationParams.Id);
            return(notificationParams.Id);
        }