Ejemplo n.º 1
0
        public void OnRegisteredSuccess(NSData token)
        {
            Debug.WriteLine("{0} - Successfully Registered.", DomainName);
            var hexDeviceToken = BitConverter.ToString(token.ToArray())
                                 .Replace("-", string.Empty).ToLowerInvariant();

            Console.WriteLine("{0} - Token: {1}", DomainName, hexDeviceToken);
            _pushNotificationListenerService.OnRegisteredAsync(hexDeviceToken, Device.iOS);
            NSUserDefaults.StandardUserDefaults.SetString(hexDeviceToken, TokenSetting);
            NSUserDefaults.StandardUserDefaults.Synchronize();
        }
        public void OnRegisteredSuccess(NSData token)
        {
            Debug.WriteLine("{0} - Successfully Registered.", DomainName);
            var trimmedDeviceToken = token.Description;

            if (!string.IsNullOrWhiteSpace(trimmedDeviceToken))
            {
                trimmedDeviceToken = trimmedDeviceToken.Trim('<').Trim('>').Trim().Replace(" ", string.Empty);
            }
            Console.WriteLine("{0} - Token: {1}", DomainName, trimmedDeviceToken);
            _pushNotificationListenerService.OnRegisteredAsync(trimmedDeviceToken, Device.iOS);
            NSUserDefaults.StandardUserDefaults.SetString(trimmedDeviceToken, TokenSetting);
            NSUserDefaults.StandardUserDefaults.Synchronize();
        }
        public async Task RegisterAsync()
        {
            var registeredToken = await _storageService.GetAsync <string>(Constants.PushRegisteredTokenKey);

            var currentToken = await GetTokenAsync();

            if (!string.IsNullOrWhiteSpace(registeredToken) && registeredToken != currentToken)
            {
                await _pushNotificationListenerService.OnRegisteredAsync(registeredToken, Device.Android);
            }
            else
            {
                await _storageService.SaveAsync(Constants.PushLastRegistrationDateKey, DateTime.UtcNow);
            }
        }
Ejemplo n.º 4
0
        public void OnRegisteredSuccess(NSData token)
        {
            Debug.WriteLine($"{TAG} - Successfully Registered.");

            var hexDeviceToken = BitConverter.ToString(token.ToArray())
                                 .Replace("-", string.Empty)
                                 .ToLowerInvariant();

            Debug.WriteLine($"{TAG} - Token: {hexDeviceToken}");

            UNUserNotificationCenter.Current.Delegate = this;

            _pushNotificationListenerService.OnRegisteredAsync(hexDeviceToken, Device.iOS);
            NSUserDefaults.StandardUserDefaults.SetString(hexDeviceToken, TokenSetting);
            NSUserDefaults.StandardUserDefaults.Synchronize();
        }