cleanup push

This commit is contained in:
Kyle Spearrin 2017-10-10 10:55:54 -04:00
parent 04e42c4a75
commit bcbdbb4932
2 changed files with 14 additions and 32 deletions

View file

@ -21,7 +21,6 @@ using Google.Analytics;
using FFImageLoading.Forms.Touch; using FFImageLoading.Forms.Touch;
using SimpleInjector; using SimpleInjector;
using XLabs.Ioc.SimpleInjectorContainer; using XLabs.Ioc.SimpleInjectorContainer;
using UserNotifications;
namespace Bit.iOS namespace Bit.iOS
{ {
@ -35,9 +34,7 @@ namespace Bit.iOS
public override bool FinishedLaunching(UIApplication app, NSDictionary options) public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{ {
global::Xamarin.Forms.Forms.Init(); Forms.Init();
UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
if(!Resolver.IsSet) if(!Resolver.IsSet)
{ {
@ -158,7 +155,6 @@ namespace Bit.iOS
Debug.WriteLine("DidEnterBackground"); Debug.WriteLine("DidEnterBackground");
} }
public override void OnResignActivation(UIApplication uiApplication) public override void OnResignActivation(UIApplication uiApplication)
{ {
base.OnResignActivation(uiApplication); base.OnResignActivation(uiApplication);
@ -206,17 +202,17 @@ namespace Bit.iOS
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error) public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{ {
if(CrossPushNotification.Current is IPushNotificationHandler) if(CrossPushNotification.Current is IPushNotificationHandler handler)
{ {
((IPushNotificationHandler)CrossPushNotification.Current).OnErrorReceived(error); handler.OnErrorReceived(error);
} }
} }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{ {
if(CrossPushNotification.Current is IPushNotificationHandler) if(CrossPushNotification.Current is IPushNotificationHandler handler)
{ {
((IPushNotificationHandler)CrossPushNotification.Current).OnRegisteredSuccess(deviceToken); handler.OnRegisteredSuccess(deviceToken);
} }
} }
@ -229,17 +225,17 @@ namespace Bit.iOS
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo,
Action<UIBackgroundFetchResult> completionHandler) Action<UIBackgroundFetchResult> completionHandler)
{ {
if(CrossPushNotification.Current is IPushNotificationHandler) if(CrossPushNotification.Current is IPushNotificationHandler handler)
{ {
((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo); handler.OnMessageReceived(userInfo);
} }
} }
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo) public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{ {
if(CrossPushNotification.Current is IPushNotificationHandler) if(CrossPushNotification.Current is IPushNotificationHandler handler)
{ {
((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo); handler.OnMessageReceived(userInfo);
} }
} }

View file

@ -105,20 +105,6 @@ namespace Bit.iOS.Services
void OnUnregisteredSuccess(); void OnUnregisteredSuccess();
} }
public class UserNotificationCenterDelegate : UNUserNotificationCenterDelegate
{
public override void WillPresentNotification(UNUserNotificationCenter center,
UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
{
Debug.WriteLine("WillPresentNotification: {0}", notification);
if(CrossPushNotification.Current is IPushNotificationHandler)
{
//((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived();
}
}
}
internal class CrossPushNotification internal class CrossPushNotification
{ {
private static Lazy<IPushNotificationService> Implementation = new Lazy<IPushNotificationService>( private static Lazy<IPushNotificationService> Implementation = new Lazy<IPushNotificationService>(