mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-14 10:15:56 +01:00
fix ios handler
This commit is contained in:
parent
3f11fdaa82
commit
309caa2f83
@ -1,4 +1,5 @@
|
||||
using Foundation;
|
||||
using Bit.App.Abstractions;
|
||||
using Foundation;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
@ -11,12 +12,12 @@ namespace Bit.iOS.Services
|
||||
private const string TokenSetting = "token";
|
||||
private const string DomainName = "iOSPushNotificationService";
|
||||
|
||||
private readonly IPushNotificationListener _pushNotificationListener;
|
||||
private readonly IPushNotificationListenerService _pushNotificationListenerService;
|
||||
|
||||
public iOSPushNotificationHandler(
|
||||
IPushNotificationListener pushNotificationListener)
|
||||
IPushNotificationListenerService pushNotificationListenerService)
|
||||
{
|
||||
_pushNotificationListener = pushNotificationListener;
|
||||
_pushNotificationListenerService = pushNotificationListenerService;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Debug.WriteLine("{0} - Registration Failed.", DomainName);
|
||||
_pushNotificationListener.OnError(error.LocalizedDescription, Device.iOS);
|
||||
_pushNotificationListenerService.OnError(error.LocalizedDescription, Device.iOS);
|
||||
}
|
||||
|
||||
public void OnRegisteredSuccess(NSData token)
|
||||
@ -52,7 +53,7 @@ namespace Bit.iOS.Services
|
||||
trimmedDeviceToken = trimmedDeviceToken.Trim('<').Trim('>').Trim().Replace(" ", string.Empty);
|
||||
}
|
||||
Console.WriteLine("{0} - Token: {1}", DomainName, trimmedDeviceToken);
|
||||
_pushNotificationListener.OnRegistered(trimmedDeviceToken, Device.iOS);
|
||||
_pushNotificationListenerService.OnRegisteredAsync(trimmedDeviceToken, Device.iOS);
|
||||
NSUserDefaults.StandardUserDefaults.SetString(trimmedDeviceToken, TokenSetting);
|
||||
NSUserDefaults.StandardUserDefaults.Synchronize();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user