mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
fix ios handler
This commit is contained in:
parent
3f11fdaa82
commit
309caa2f83
1 changed files with 8 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
using Foundation;
|
using Bit.App.Abstractions;
|
||||||
|
using Foundation;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -11,12 +12,12 @@ namespace Bit.iOS.Services
|
||||||
private const string TokenSetting = "token";
|
private const string TokenSetting = "token";
|
||||||
private const string DomainName = "iOSPushNotificationService";
|
private const string DomainName = "iOSPushNotificationService";
|
||||||
|
|
||||||
private readonly IPushNotificationListener _pushNotificationListener;
|
private readonly IPushNotificationListenerService _pushNotificationListenerService;
|
||||||
|
|
||||||
public iOSPushNotificationHandler(
|
public iOSPushNotificationHandler(
|
||||||
IPushNotificationListener pushNotificationListener)
|
IPushNotificationListenerService pushNotificationListenerService)
|
||||||
{
|
{
|
||||||
_pushNotificationListener = pushNotificationListener;
|
_pushNotificationListenerService = pushNotificationListenerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMessageReceived(NSDictionary userInfo)
|
public void OnMessageReceived(NSDictionary userInfo)
|
||||||
|
@ -34,13 +35,13 @@ namespace Bit.iOS.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_pushNotificationListener.OnMessage(values, Device.iOS);
|
_pushNotificationListenerService.OnMessageAsync(values, Device.iOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnErrorReceived(NSError error)
|
public void OnErrorReceived(NSError error)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("{0} - Registration Failed.", DomainName);
|
Debug.WriteLine("{0} - Registration Failed.", DomainName);
|
||||||
_pushNotificationListener.OnError(error.LocalizedDescription, Device.iOS);
|
_pushNotificationListenerService.OnError(error.LocalizedDescription, Device.iOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRegisteredSuccess(NSData token)
|
public void OnRegisteredSuccess(NSData token)
|
||||||
|
@ -52,7 +53,7 @@ namespace Bit.iOS.Services
|
||||||
trimmedDeviceToken = trimmedDeviceToken.Trim('<').Trim('>').Trim().Replace(" ", string.Empty);
|
trimmedDeviceToken = trimmedDeviceToken.Trim('<').Trim('>').Trim().Replace(" ", string.Empty);
|
||||||
}
|
}
|
||||||
Console.WriteLine("{0} - Token: {1}", DomainName, trimmedDeviceToken);
|
Console.WriteLine("{0} - Token: {1}", DomainName, trimmedDeviceToken);
|
||||||
_pushNotificationListener.OnRegistered(trimmedDeviceToken, Device.iOS);
|
_pushNotificationListenerService.OnRegisteredAsync(trimmedDeviceToken, Device.iOS);
|
||||||
NSUserDefaults.StandardUserDefaults.SetString(trimmedDeviceToken, TokenSetting);
|
NSUserDefaults.StandardUserDefaults.SetString(trimmedDeviceToken, TokenSetting);
|
||||||
NSUserDefaults.StandardUserDefaults.Synchronize();
|
NSUserDefaults.StandardUserDefaults.Synchronize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue