Esempio n. 1
0
        //本地推送 你可以传入一个固定的推送时间
        public override void AddNotificationMessage(string title, string message, System.DateTime newDate, string loopType, int badgeNum)
        {
            //推送时间需要大于当前时间
            if (newDate > System.DateTime.Now)
            {
                UnityEngine.iOS.NotificationType notifiType = new UnityEngine.iOS.NotificationType();
                notifiType = UnityEngine.iOS.NotificationType.Alert;
                notifiType = UnityEngine.iOS.NotificationType.Badge;
                notifiType = UnityEngine.iOS.NotificationType.Sound;
                UnityEngine.iOS.NotificationServices.RegisterForNotifications(notifiType);


                UnityEngine.iOS.LocalNotification localNotification = new UnityEngine.iOS.LocalNotification();
                localNotification.fireDate    = newDate;
                localNotification.alertBody   = message;
                localNotification.alertAction = title;
                localNotification.applicationIconBadgeNumber = 1;
                localNotification.hasAction = true;
                if (loopType == "day")
                {
                    //是否每天定期循环
                    localNotification.repeatCalendar = UnityEngine.iOS.CalendarIdentifier.ChineseCalendar;
                    localNotification.repeatInterval = UnityEngine.iOS.CalendarUnit.Day;
                }
                else if (loopType == "week")
                {
                    //是否每周定期循环
                    localNotification.repeatCalendar = UnityEngine.iOS.CalendarIdentifier.ChineseCalendar;
                    localNotification.repeatInterval = UnityEngine.iOS.CalendarUnit.Week;
                }
                localNotification.soundName = UnityEngine.iOS.LocalNotification.defaultSoundName;
                UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(localNotification);
            }
        }
 public void RegisterForRemoteNotifications(UnityEngine.iOS.NotificationType notificationTypes)
 {
             #if (UNITY_IPHONE && !UNITY_EDITOR && PUSH_ENABLED) || SA_DEBUG_MODE
     NotificationServices.RegisterForRemoteNotificationTypes(notificationTypes);
     DeviceTokenListner.Create();
             #endif
 }
Esempio n. 3
0
 public bool CheckPushAgree()
 {
             #if (UNITY_ANDROID)
             #else
     UnityEngine.iOS.NotificationType type = UnityEngine.iOS.NotificationServices.enabledNotificationTypes;
     if (type == UnityEngine.iOS.NotificationType.None || type == 0)
     {
         return(true);
     }
             #endif
     return(false);
 }
    public static bool Allowed()
    {
                #if UNITY_EDITOR
        return(true);
                #endif

                #if UNITY_IPHONE
        UnityEngine.iOS.NotificationType type = UnityEngine.iOS.NotificationServices.enabledNotificationTypes;

        if (type != UnityEngine.iOS.NotificationType.None)
        {
            return(true);
        }

        return(false);
                #endif

                #if UNITY_ANDROID
        return(true);
                #endif
    }
        private static void RegisterForRemoteNotifications()
        {
            //NotificationServices.RegisterForRemoteNotificationTypes(GamedoniaPushNotifications.notificationType);

            if (GamedoniaPushNotifications.Instance.enableBadge)
            {
                notificationType |= RemoteNotificationType.Badge;
            }
            if (GamedoniaPushNotifications.Instance.enableAlert)
            {
                notificationType |= RemoteNotificationType.Alert;
            }
            if (GamedoniaPushNotifications.Instance.enableSound)
            {
                notificationType |= RemoteNotificationType.Sound;
            }

            string sysInfo = SystemInfo.operatingSystem;

            sysInfo = sysInfo.Replace("iPhone OS ", "");
            string[] chunks       = sysInfo.Split('.');
            int      majorVersion = int.Parse(chunks[0]);

            if (majorVersion >= 8)
            {
                if (Instance.debug)
                {
                    Debug.Log("[Register Notification] major Version > 8");
                }
                _RegisterForRemoteNotifications((int)GamedoniaPushNotifications.notificationType);
            }
            else
            {
                if (Instance.debug)
                {
                    Debug.Log("[Register Notification] Unity Standard registration process");
                }
                NotificationServices.RegisterForRemoteNotificationTypes(GamedoniaPushNotifications.notificationType);
            }
        }