From f3a17709e5021bee7ea12bdc0caee154e03c56a6 Mon Sep 17 00:00:00 2001 From: kspearrin Date: Mon, 30 Sep 2019 16:24:35 -0400 Subject: [PATCH] get proper hex string from nsdata token --- src/iOS/Services/iOSPushNotificationHandler.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/iOS/Services/iOSPushNotificationHandler.cs b/src/iOS/Services/iOSPushNotificationHandler.cs index 8592e2c0c..ae6092424 100644 --- a/src/iOS/Services/iOSPushNotificationHandler.cs +++ b/src/iOS/Services/iOSPushNotificationHandler.cs @@ -47,14 +47,11 @@ namespace Bit.iOS.Services 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); + 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(); }