Ejemplo n.º 1
0
 public void RegisterForRemoteNotifications(RemoteNotificationType notificationTypes)
 {
             #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
     NotificationServices.RegisterForRemoteNotificationTypes(notificationTypes);
     DeviceTokenListner.Create();
             #endif
 }
        public override void RegisterForRemoteNotifications(string senderId, RemoteNotificationType[] types)
        {
            SystemLogger.Log(SystemLogger.Module.PLATFORM,"Registering senderId ["+ senderId +"] for receiving  push notifications");

            UIApplication.SharedApplication.InvokeOnMainThread (delegate {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.None;
                try {
                    if(types != null) {
                        SystemLogger.Log(SystemLogger.Module.PLATFORM,"Remote Notifications types enabled #num : " + types.Length);
                        foreach(RemoteNotificationType notificationType in types) {
                            notificationTypes = notificationTypes | rnTypes[notificationType] ;
                        }
                    }

                    SystemLogger.Log(SystemLogger.Module.PLATFORM,"Remote Notifications types enabled: " + notificationTypes);
                    if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
                        UIUserNotificationType uiUserNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                        var settings = UIUserNotificationSettings.GetSettingsForTypes(uiUserNotificationTypes, new NSSet (new string[] {}));
                        UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);
                    }else{

                        //This tells our app to go ahead and ask the user for permission to use Push Notifications
                        // You have to specify which types you want to ask permission for
                        // Most apps just ask for them all and if they don't use one type, who cares
                        UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
                    }
                } catch(Exception e) {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM,"Exception ocurred: " + e.Message);
                }
            });
        }
    public void RegisterForRemoteNotifications(RemoteNotificationType notificationTypes)
    {
                #if (UNITY_IPHONE && !UNITY_EDITOR && PUSH_ENABLED) || SA_DEBUG_MODE
        string sysInfo = SystemInfo.operatingSystem;
        sysInfo = sysInfo.Replace("iPhone OS ", "");
        string[] chunks       = sysInfo.Split('.');
        int      majorVersion = int.Parse(chunks[0]);
        if (majorVersion >= 8)
        {
            _ISN_RegisterForRemoteNotifications((int)notificationTypes);
        }
        else
        {
            NotificationServices.RegisterForRemoteNotificationTypes(notificationTypes);
        }


        DeviceTokenListner.Create();
                #endif
    }
Ejemplo n.º 4
0
    public static void JceNotiTokenSetting(AmUser user)
    {
        Ag.LogStartWithStr(2, "   JceNotiTokenSetting  >>      Started   .........  . . . . . . ");
        WebClient webClient = new WebClient();

        webClient.QueryString.Add("uid", Ag.mySelf.WAS.KkoID);  //"88865833564111728");
        webClient.QueryString.Add("gcode", "113");
        #if UNITY_IPHONE
        RemoteNotificationType arrNotiType = NotificationServices.enabledRemoteNotificationTypes;
        Ag.LogString(" Device Model ::  " + SystemInfo.deviceModel);
//        if (SystemInfo.deviceModel.Substring (0, 4) == "iPad")
//            webClient.QueryString.Add ("device", "3");
//        else
        webClient.QueryString.Add("device", "2");
        #endif
        #if UNITY_ANDROID
        webClient.QueryString.Add("device", "1");
        #endif

        string tken = JCE.GetToken();

        AgStt.PushURI.HtLog();

        if (tken == "ERROR")
        {
            Ag.LogIntenseWord("   Notification Token  Error    ");
            return;
        }

        webClient.QueryString.Add("token", JCE.GetToken());
        string result;
        string pushUrl = AgStt.PushURI + "/token/setting.json";
        if (!JCE.WebDownloadString(webClient, pushUrl, out result))
        {
            return;
        }
        ("   JceNotiTokenSetting  >>  Received :::   " + result).HtLog();
        //JSONNode jnObj = JSON.Parse (result);
        return;
    }
Ejemplo n.º 5
0
    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);
        }
    }
        public async override Task RegisterForRemoteNotifications(string senderId, RemoteNotificationType[] types)
        {
            try
            {

                _pushNotificationChannel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

                _pushNotificationChannel.PushNotificationReceived += OnPushNotificationReceived;

                var registrationToken = new RegistrationToken
                {
                    Binary = Encoding.UTF8.GetBytes(_pushNotificationChannel.Uri),
                    StringRepresentation = _pushNotificationChannel.Uri
                };
                WindowsPhoneUtils.InvokeCallback("Appverse.PushNotifications.OnRegisterForRemoteNotificationsSuccess", WindowsPhoneUtils.CALLBACKID, JsonConvert.SerializeObject(registrationToken));
            }
            catch (Exception ex)
            {

                var registrationError = new RegistrationError
                {
                    Code = ex.HResult.ToString(),
                    LocalizedDescription = ex.Message
                };
                WindowsPhoneUtils.InvokeCallback("Appverse.PushNotifications.OnRegisterForRemoteNotificationsFailure", WindowsPhoneUtils.CALLBACKID, JsonConvert.SerializeObject(registrationError));
            }
        }
Ejemplo n.º 7
0
 public abstract void RegisterForRemoteNotifications(string senderId, RemoteNotificationType[] types);
Ejemplo n.º 8
0
 public void RegisterForRemoteNotifications(RemoteNotificationType notificationTypes)
 {
Ejemplo n.º 9
0
		public static void RegisterForRemoteNotificationTypes(RemoteNotificationType notificationTypes){}
Ejemplo n.º 10
0
        public override void RegisterForRemoteNotifications(string senderId, RemoteNotificationType[] types)
        {
            SystemLogger.Log(SystemLogger.Module.PLATFORM,"Registering senderId ["+ senderId +"] for receiving  push notifications");

            UIApplication.SharedApplication.InvokeOnMainThread (delegate {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.None;
                try {
                    if(types != null) {
                        SystemLogger.Log(SystemLogger.Module.PLATFORM,"Remote Notifications types enabled #num : " + types.Length);
                        foreach(RemoteNotificationType notificationType in types) {
                            notificationTypes = notificationTypes | rnTypes[notificationType] ;
                        }
                    }

                    SystemLogger.Log(SystemLogger.Module.PLATFORM,"Remote Notifications types enabled: " + notificationTypes);

                    //This tells our app to go ahead and ask the user for permission to use Push Notifications
                    // You have to specify which types you want to ask permission for
                    // Most apps just ask for them all and if they don't use one type, who cares
                    UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
                } catch(Exception e) {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM,"Exception ocurred: " + e.Message);
                }
            });
        }