2016-05-02 08:52:09 +02:00
|
|
|
|
using System;
|
|
|
|
|
using XLabs.Ioc;
|
|
|
|
|
using Foundation;
|
|
|
|
|
using UIKit;
|
|
|
|
|
using Bit.App.Abstractions;
|
|
|
|
|
using Bit.App.Services;
|
|
|
|
|
using Bit.iOS.Services;
|
2016-05-03 08:08:50 +02:00
|
|
|
|
using Plugin.Connectivity;
|
2016-05-06 06:17:38 +02:00
|
|
|
|
using Bit.App.Repositories;
|
2016-05-21 18:32:34 +02:00
|
|
|
|
using Plugin.Fingerprint;
|
|
|
|
|
using Plugin.Settings.Abstractions;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Xamarin.Forms;
|
2016-05-28 22:06:53 +02:00
|
|
|
|
using Bit.iOS.Core.Services;
|
2016-07-02 00:54:00 +02:00
|
|
|
|
using Plugin.Connectivity.Abstractions;
|
2016-07-05 05:11:44 +02:00
|
|
|
|
using Bit.App.Pages;
|
2016-07-22 06:04:05 +02:00
|
|
|
|
using HockeyApp.iOS;
|
2016-07-22 23:55:11 +02:00
|
|
|
|
using Bit.iOS.Core;
|
2016-08-05 01:35:56 +02:00
|
|
|
|
using Google.Analytics;
|
2017-02-16 03:56:02 +01:00
|
|
|
|
using FFImageLoading.Forms.Touch;
|
2017-06-01 20:49:48 +02:00
|
|
|
|
using SimpleInjector;
|
|
|
|
|
using XLabs.Ioc.SimpleInjectorContainer;
|
2018-05-24 17:41:57 +02:00
|
|
|
|
using CoreNFC;
|
2018-05-24 21:34:09 +02:00
|
|
|
|
using Bit.App.Resources;
|
2016-05-02 08:52:09 +02:00
|
|
|
|
|
|
|
|
|
namespace Bit.iOS
|
|
|
|
|
{
|
|
|
|
|
[Register("AppDelegate")]
|
|
|
|
|
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
|
|
|
|
|
{
|
2016-08-05 01:35:56 +02:00
|
|
|
|
private GaiCompletionHandler _dispatchHandler = null;
|
2018-05-24 18:49:22 +02:00
|
|
|
|
private NFCNdefReaderSession _nfcSession = null;
|
2017-04-28 17:07:26 +02:00
|
|
|
|
private ILockService _lockService;
|
2018-05-24 17:41:57 +02:00
|
|
|
|
private IDeviceInfoService _deviceInfoService;
|
2017-12-22 05:26:46 +01:00
|
|
|
|
private iOSPushNotificationHandler _pushHandler = null;
|
2018-05-25 04:33:29 +02:00
|
|
|
|
private NFCReaderDelegate _nfcDelegate = null;
|
2016-08-05 01:35:56 +02:00
|
|
|
|
|
2016-06-25 05:39:13 +02:00
|
|
|
|
public ISettings Settings { get; set; }
|
|
|
|
|
|
2016-05-02 08:52:09 +02:00
|
|
|
|
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
|
|
|
|
{
|
2017-10-10 16:55:54 +02:00
|
|
|
|
Forms.Init();
|
2017-10-10 15:13:09 +02:00
|
|
|
|
|
2016-05-02 08:52:09 +02:00
|
|
|
|
if(!Resolver.IsSet)
|
|
|
|
|
{
|
|
|
|
|
SetIoc();
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-28 17:07:26 +02:00
|
|
|
|
_lockService = Resolver.Resolve<ILockService>();
|
2018-05-24 17:41:57 +02:00
|
|
|
|
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
2017-12-22 05:26:46 +01:00
|
|
|
|
_pushHandler = new iOSPushNotificationHandler(Resolver.Resolve<IPushNotificationListener>());
|
2018-05-25 04:33:29 +02:00
|
|
|
|
_nfcDelegate = new NFCReaderDelegate((success, message) => ProcessYubikey(success, message));
|
2016-07-28 00:46:55 +02:00
|
|
|
|
var appIdService = Resolver.Resolve<IAppIdService>();
|
2017-12-22 05:26:46 +01:00
|
|
|
|
|
2016-07-28 00:46:55 +02:00
|
|
|
|
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
|
|
|
|
|
appIdService, Resolver.Resolve<IAuthService>());
|
2016-07-22 23:55:11 +02:00
|
|
|
|
var manager = BITHockeyManager.SharedHockeyManager;
|
|
|
|
|
manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
|
2016-07-23 04:56:45 +02:00
|
|
|
|
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
|
2016-07-28 00:46:55 +02:00
|
|
|
|
manager.UserId = appIdService.AppId;
|
2016-07-22 23:55:11 +02:00
|
|
|
|
manager.StartManager();
|
|
|
|
|
manager.Authenticator.AuthenticateInstallation();
|
2016-08-14 06:15:47 +02:00
|
|
|
|
manager.DisableMetricsManager = manager.DisableFeedbackManager = manager.DisableUpdateManager = true;
|
2016-07-22 23:55:11 +02:00
|
|
|
|
|
2016-05-22 05:26:35 +02:00
|
|
|
|
LoadApplication(new App.App(
|
2017-01-28 05:13:28 +01:00
|
|
|
|
null,
|
2016-05-21 18:32:34 +02:00
|
|
|
|
Resolver.Resolve<IAuthService>(),
|
2016-07-02 00:54:00 +02:00
|
|
|
|
Resolver.Resolve<IConnectivity>(),
|
2016-05-21 18:32:34 +02:00
|
|
|
|
Resolver.Resolve<IDatabaseService>(),
|
2016-07-01 02:08:34 +02:00
|
|
|
|
Resolver.Resolve<ISyncService>(),
|
2016-07-20 00:46:39 +02:00
|
|
|
|
Resolver.Resolve<ISettings>(),
|
2017-04-28 17:07:26 +02:00
|
|
|
|
_lockService,
|
2017-02-06 05:55:46 +01:00
|
|
|
|
Resolver.Resolve<ILocalizeService>(),
|
2017-04-28 17:07:26 +02:00
|
|
|
|
Resolver.Resolve<IAppInfoService>(),
|
2017-07-13 16:51:45 +02:00
|
|
|
|
Resolver.Resolve<IAppSettingsService>(),
|
|
|
|
|
Resolver.Resolve<IDeviceActionService>()));
|
2016-05-02 08:52:09 +02:00
|
|
|
|
|
2016-07-12 05:55:16 +02:00
|
|
|
|
// Appearance stuff
|
|
|
|
|
|
|
|
|
|
var primaryColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
|
2016-07-13 00:59:09 +02:00
|
|
|
|
var grayLight = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);
|
2016-07-12 05:55:16 +02:00
|
|
|
|
|
2016-06-14 06:19:18 +02:00
|
|
|
|
UINavigationBar.Appearance.ShadowImage = new UIImage();
|
|
|
|
|
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
|
2016-07-12 05:55:16 +02:00
|
|
|
|
UIBarButtonItem.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
|
2017-10-10 16:55:54 +02:00
|
|
|
|
UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).SetTitleColor(primaryColor,
|
2017-10-10 05:45:23 +02:00
|
|
|
|
UIControlState.Normal);
|
2016-07-30 18:51:12 +02:00
|
|
|
|
UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
|
2016-07-13 00:59:09 +02:00
|
|
|
|
UIStepper.Appearance.TintColor = grayLight;
|
|
|
|
|
UISlider.Appearance.TintColor = primaryColor;
|
2016-06-14 06:19:18 +02:00
|
|
|
|
|
2017-10-10 05:45:23 +02:00
|
|
|
|
MessagingCenter.Subscribe<Xamarin.Forms.Application, ToolsExtensionPage>(
|
|
|
|
|
Xamarin.Forms.Application.Current, "ShowAppExtension", (sender, page) =>
|
2016-07-02 21:20:06 +02:00
|
|
|
|
{
|
2017-10-10 05:45:23 +02:00
|
|
|
|
var itemProvider = new NSItemProvider(new NSDictionary(), Core.Constants.UTTypeAppExtensionSetup);
|
2016-07-02 21:20:06 +02:00
|
|
|
|
var extensionItem = new NSExtensionItem();
|
|
|
|
|
extensionItem.Attachments = new NSItemProvider[] { itemProvider };
|
|
|
|
|
var activityViewController = new UIActivityViewController(new NSExtensionItem[] { extensionItem }, null);
|
|
|
|
|
activityViewController.CompletionHandler = (activityType, completed) =>
|
|
|
|
|
{
|
2016-07-05 05:11:44 +02:00
|
|
|
|
page.EnabledExtension(completed && activityType == "com.8bit.bitwarden.find-login-action-extension");
|
2016-07-02 21:20:06 +02:00
|
|
|
|
};
|
|
|
|
|
|
2016-07-10 07:15:59 +02:00
|
|
|
|
var modal = UIApplication.SharedApplication.KeyWindow.RootViewController.ModalViewController;
|
|
|
|
|
if(activityViewController.PopoverPresentationController != null)
|
|
|
|
|
{
|
|
|
|
|
activityViewController.PopoverPresentationController.SourceView = modal.View;
|
|
|
|
|
var frame = UIScreen.MainScreen.Bounds;
|
|
|
|
|
frame.Height /= 2;
|
|
|
|
|
activityViewController.PopoverPresentationController.SourceRect = frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modal.PresentViewController(activityViewController, true, null);
|
2016-07-02 21:20:06 +02:00
|
|
|
|
});
|
|
|
|
|
|
2018-05-24 17:41:57 +02:00
|
|
|
|
MessagingCenter.Subscribe<Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current,
|
|
|
|
|
"ListenYubiKeyOTP", (sender, listen) =>
|
|
|
|
|
{
|
|
|
|
|
if(!_deviceInfoService.NfcEnabled)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-25 04:33:29 +02:00
|
|
|
|
_nfcSession?.InvalidateSession();
|
|
|
|
|
_nfcSession?.Dispose();
|
|
|
|
|
_nfcSession = null;
|
2018-05-24 18:49:22 +02:00
|
|
|
|
if(listen)
|
2018-05-24 17:41:57 +02:00
|
|
|
|
{
|
2018-05-25 04:33:29 +02:00
|
|
|
|
_nfcSession = new NFCNdefReaderSession(_nfcDelegate, null, true);
|
2018-05-24 21:34:09 +02:00
|
|
|
|
_nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop;
|
2018-05-24 18:49:22 +02:00
|
|
|
|
_nfcSession.BeginSession();
|
|
|
|
|
}
|
2018-05-24 17:41:57 +02:00
|
|
|
|
});
|
|
|
|
|
|
2016-07-23 21:32:11 +02:00
|
|
|
|
UIApplication.SharedApplication.StatusBarHidden = false;
|
|
|
|
|
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
|
|
|
|
|
|
2017-10-10 16:55:54 +02:00
|
|
|
|
MessagingCenter.Subscribe<Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current,
|
2017-10-10 05:45:23 +02:00
|
|
|
|
"ShowStatusBar", (sender, show) =>
|
2016-07-23 21:32:11 +02:00
|
|
|
|
{
|
|
|
|
|
UIApplication.SharedApplication.SetStatusBarHidden(!show, false);
|
|
|
|
|
});
|
|
|
|
|
|
2017-07-13 23:23:18 +02:00
|
|
|
|
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
|
2016-05-02 08:52:09 +02:00
|
|
|
|
return base.FinishedLaunching(app, options);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-21 18:32:34 +02:00
|
|
|
|
public override void DidEnterBackground(UIApplication uiApplication)
|
|
|
|
|
{
|
2016-06-11 08:43:53 +02:00
|
|
|
|
var view = new UIView(UIApplication.SharedApplication.KeyWindow.Frame)
|
2016-05-21 18:32:34 +02:00
|
|
|
|
{
|
|
|
|
|
Tag = 4321
|
|
|
|
|
};
|
2016-06-11 08:43:53 +02:00
|
|
|
|
|
|
|
|
|
var backgroundView = new UIView(UIApplication.SharedApplication.KeyWindow.Frame)
|
|
|
|
|
{
|
2016-06-26 02:54:17 +02:00
|
|
|
|
BackgroundColor = new UIColor(red: 0.93f, green: 0.94f, blue: 0.96f, alpha: 1.0f)
|
2016-06-11 08:43:53 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var imageView = new UIImageView(new UIImage("logo.png"))
|
|
|
|
|
{
|
2016-07-27 04:41:01 +02:00
|
|
|
|
Center = new CoreGraphics.CGPoint(view.Center.X, view.Center.Y - 30)
|
2016-06-11 08:43:53 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
view.AddSubview(backgroundView);
|
|
|
|
|
view.AddSubview(imageView);
|
|
|
|
|
|
|
|
|
|
UIApplication.SharedApplication.KeyWindow.AddSubview(view);
|
|
|
|
|
UIApplication.SharedApplication.KeyWindow.BringSubviewToFront(view);
|
|
|
|
|
UIApplication.SharedApplication.KeyWindow.EndEditing(true);
|
2016-07-24 05:50:08 +02:00
|
|
|
|
UIApplication.SharedApplication.SetStatusBarHidden(true, false);
|
2016-05-22 04:50:15 +02:00
|
|
|
|
|
|
|
|
|
// Log the date/time we last backgrounded
|
2017-04-28 17:07:26 +02:00
|
|
|
|
_lockService.UpdateLastActivity();
|
2016-06-25 05:39:13 +02:00
|
|
|
|
|
2016-08-05 01:35:56 +02:00
|
|
|
|
// Dispatch Google Analytics
|
|
|
|
|
SendGoogleAnalyticsHitsInBackground();
|
2016-05-21 18:32:34 +02:00
|
|
|
|
|
|
|
|
|
base.DidEnterBackground(uiApplication);
|
|
|
|
|
Debug.WriteLine("DidEnterBackground");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnResignActivation(UIApplication uiApplication)
|
|
|
|
|
{
|
|
|
|
|
base.OnResignActivation(uiApplication);
|
|
|
|
|
Debug.WriteLine("OnResignActivation");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void WillTerminate(UIApplication uiApplication)
|
|
|
|
|
{
|
|
|
|
|
base.WillTerminate(uiApplication);
|
|
|
|
|
Debug.WriteLine("WillTerminate");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnActivated(UIApplication uiApplication)
|
|
|
|
|
{
|
|
|
|
|
base.OnActivated(uiApplication);
|
|
|
|
|
Debug.WriteLine("OnActivated");
|
|
|
|
|
|
2016-07-23 21:09:00 +02:00
|
|
|
|
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
|
|
|
|
|
|
2016-05-21 18:32:34 +02:00
|
|
|
|
var view = UIApplication.SharedApplication.KeyWindow.ViewWithTag(4321);
|
|
|
|
|
if(view != null)
|
|
|
|
|
{
|
|
|
|
|
view.RemoveFromSuperview();
|
2016-07-24 05:50:08 +02:00
|
|
|
|
UIApplication.SharedApplication.SetStatusBarHidden(false, false);
|
2016-05-21 18:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void WillEnterForeground(UIApplication uiApplication)
|
|
|
|
|
{
|
2016-07-01 02:08:34 +02:00
|
|
|
|
SendResumedMessage();
|
2016-08-05 01:35:56 +02:00
|
|
|
|
|
|
|
|
|
// Restores the dispatch interval because dispatchWithCompletionHandler
|
|
|
|
|
// has disabled automatic dispatching.
|
|
|
|
|
Gai.SharedInstance.DispatchInterval = 10;
|
|
|
|
|
|
2016-05-21 18:32:34 +02:00
|
|
|
|
base.WillEnterForeground(uiApplication);
|
|
|
|
|
Debug.WriteLine("WillEnterForeground");
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 16:55:54 +02:00
|
|
|
|
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication,
|
2017-10-10 05:45:23 +02:00
|
|
|
|
NSObject annotation)
|
2016-05-30 09:08:12 +02:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-18 08:45:46 +02:00
|
|
|
|
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
|
|
|
|
|
{
|
2017-12-22 05:26:46 +01:00
|
|
|
|
_pushHandler?.OnErrorReceived(error);
|
2016-06-18 08:45:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
|
|
|
|
|
{
|
2017-12-22 05:26:46 +01:00
|
|
|
|
_pushHandler?.OnRegisteredSuccess(deviceToken);
|
2016-06-18 08:45:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 16:55:54 +02:00
|
|
|
|
public override void DidRegisterUserNotificationSettings(UIApplication application,
|
2017-10-10 05:45:23 +02:00
|
|
|
|
UIUserNotificationSettings notificationSettings)
|
2016-06-18 08:45:46 +02:00
|
|
|
|
{
|
|
|
|
|
application.RegisterForRemoteNotifications();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 16:55:54 +02:00
|
|
|
|
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo,
|
2017-10-10 05:45:23 +02:00
|
|
|
|
Action<UIBackgroundFetchResult> completionHandler)
|
2016-06-18 08:45:46 +02:00
|
|
|
|
{
|
2017-12-22 05:26:46 +01:00
|
|
|
|
_pushHandler?.OnMessageReceived(userInfo);
|
2016-06-18 08:45:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
|
|
|
|
|
{
|
2017-12-22 05:26:46 +01:00
|
|
|
|
_pushHandler?.OnMessageReceived(userInfo);
|
2016-06-18 08:45:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 02:08:34 +02:00
|
|
|
|
private void SendResumedMessage()
|
2016-05-21 18:32:34 +02:00
|
|
|
|
{
|
2016-07-01 02:08:34 +02:00
|
|
|
|
MessagingCenter.Send(Xamarin.Forms.Application.Current, "Resumed", false);
|
2016-05-21 18:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-02 08:52:09 +02:00
|
|
|
|
private void SetIoc()
|
|
|
|
|
{
|
2017-06-01 20:49:48 +02:00
|
|
|
|
var container = new Container();
|
|
|
|
|
|
|
|
|
|
// Services
|
|
|
|
|
container.RegisterSingleton<IDatabaseService, DatabaseService>();
|
|
|
|
|
container.RegisterSingleton<ISqlService, SqlService>();
|
|
|
|
|
container.RegisterSingleton<ISecureStorageService, KeyChainStorageService>();
|
|
|
|
|
container.RegisterSingleton<ICryptoService, CryptoService>();
|
|
|
|
|
container.RegisterSingleton<IKeyDerivationService, CommonCryptoKeyDerivationService>();
|
|
|
|
|
container.RegisterSingleton<IAuthService, AuthService>();
|
|
|
|
|
container.RegisterSingleton<IFolderService, FolderService>();
|
2017-11-25 05:15:25 +01:00
|
|
|
|
container.RegisterSingleton<ICollectionService, CollectionService>();
|
2017-10-19 02:55:33 +02:00
|
|
|
|
container.RegisterSingleton<ICipherService, CipherService>();
|
2017-06-01 20:49:48 +02:00
|
|
|
|
container.RegisterSingleton<ISyncService, SyncService>();
|
2017-07-13 05:09:44 +02:00
|
|
|
|
container.RegisterSingleton<IDeviceActionService, DeviceActionService>();
|
2017-06-01 20:49:48 +02:00
|
|
|
|
container.RegisterSingleton<IAppIdService, AppIdService>();
|
|
|
|
|
container.RegisterSingleton<IPasswordGenerationService, PasswordGenerationService>();
|
|
|
|
|
container.RegisterSingleton<ILockService, LockService>();
|
|
|
|
|
container.RegisterSingleton<IAppInfoService, AppInfoService>();
|
|
|
|
|
container.RegisterSingleton<IGoogleAnalyticsService, GoogleAnalyticsService>();
|
|
|
|
|
container.RegisterSingleton<IDeviceInfoService, DeviceInfoService>();
|
|
|
|
|
container.RegisterSingleton<ILocalizeService, LocalizeService>();
|
|
|
|
|
container.RegisterSingleton<ILogService, LogService>();
|
|
|
|
|
container.RegisterSingleton<IHttpService, HttpService>();
|
|
|
|
|
container.RegisterSingleton<ITokenService, TokenService>();
|
|
|
|
|
container.RegisterSingleton<ISettingsService, SettingsService>();
|
|
|
|
|
container.RegisterSingleton<IAppSettingsService, AppSettingsService>();
|
|
|
|
|
|
|
|
|
|
// Repositories
|
|
|
|
|
container.RegisterSingleton<IFolderRepository, FolderRepository>();
|
|
|
|
|
container.RegisterSingleton<IFolderApiRepository, FolderApiRepository>();
|
2017-10-19 02:55:33 +02:00
|
|
|
|
container.RegisterSingleton<ICipherRepository, CipherRepository>();
|
2017-07-12 22:23:24 +02:00
|
|
|
|
container.RegisterSingleton<IAttachmentRepository, AttachmentRepository>();
|
2017-06-01 20:49:48 +02:00
|
|
|
|
container.RegisterSingleton<IConnectApiRepository, ConnectApiRepository>();
|
|
|
|
|
container.RegisterSingleton<IDeviceApiRepository, DeviceApiRepository>();
|
|
|
|
|
container.RegisterSingleton<IAccountsApiRepository, AccountsApiRepository>();
|
|
|
|
|
container.RegisterSingleton<ICipherApiRepository, CipherApiRepository>();
|
|
|
|
|
container.RegisterSingleton<ISettingsRepository, SettingsRepository>();
|
|
|
|
|
container.RegisterSingleton<ISettingsApiRepository, SettingsApiRepository>();
|
2017-06-29 17:22:06 +02:00
|
|
|
|
container.RegisterSingleton<ITwoFactorApiRepository, TwoFactorApiRepository>();
|
2017-09-20 19:17:05 +02:00
|
|
|
|
container.RegisterSingleton<ISyncApiRepository, SyncApiRepository>();
|
2017-11-24 22:11:40 +01:00
|
|
|
|
container.RegisterSingleton<ICollectionRepository, CollectionRepository>();
|
|
|
|
|
container.RegisterSingleton<ICipherCollectionRepository, CipherCollectionRepository>();
|
2017-06-01 20:49:48 +02:00
|
|
|
|
|
|
|
|
|
// Other
|
|
|
|
|
container.RegisterSingleton(CrossConnectivity.Current);
|
|
|
|
|
container.RegisterSingleton(CrossFingerprint.Current);
|
2016-05-02 08:52:09 +02:00
|
|
|
|
|
2016-06-25 05:39:13 +02:00
|
|
|
|
Settings = new Settings("group.com.8bit.bitwarden");
|
2017-06-01 20:49:48 +02:00
|
|
|
|
container.RegisterSingleton(Settings);
|
2016-06-25 05:39:13 +02:00
|
|
|
|
|
2017-06-01 20:49:48 +02:00
|
|
|
|
// Push
|
2017-12-22 05:26:46 +01:00
|
|
|
|
container.RegisterSingleton<IPushNotificationListener, PushNotificationListener>();
|
|
|
|
|
container.RegisterSingleton<IPushNotificationService, iOSPushNotificationService>();
|
2016-06-18 08:45:46 +02:00
|
|
|
|
|
2017-12-22 05:26:46 +01:00
|
|
|
|
CachedImageRenderer.Init();
|
2017-06-01 20:49:48 +02:00
|
|
|
|
Resolver.SetResolver(new SimpleInjectorResolver(container));
|
2016-05-02 08:52:09 +02:00
|
|
|
|
}
|
2016-08-05 01:35:56 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This method sends any queued hits when the app enters the background.
|
|
|
|
|
/// ref: https://developers.google.com/analytics/devguides/collection/ios/v3/dispatch
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SendGoogleAnalyticsHitsInBackground()
|
|
|
|
|
{
|
|
|
|
|
var taskExpired = false;
|
|
|
|
|
var taskId = UIApplication.SharedApplication.BeginBackgroundTask(() =>
|
|
|
|
|
{
|
|
|
|
|
taskExpired = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if(taskId == UIApplication.BackgroundTaskInvalid)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dispatchHandler = (result) =>
|
|
|
|
|
{
|
|
|
|
|
// Send hits until no hits are left, a dispatch error occurs, or the background task expires.
|
|
|
|
|
if(_dispatchHandler != null && result == DispatchResult.Good && !taskExpired)
|
|
|
|
|
{
|
|
|
|
|
Gai.SharedInstance.Dispatch(_dispatchHandler);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UIApplication.SharedApplication.EndBackgroundTask(taskId);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Gai.SharedInstance.Dispatch(_dispatchHandler);
|
|
|
|
|
}
|
2018-05-25 04:33:29 +02:00
|
|
|
|
|
|
|
|
|
private void ProcessYubikey(bool success, string message)
|
|
|
|
|
{
|
|
|
|
|
if(success)
|
|
|
|
|
{
|
|
|
|
|
Device.BeginInvokeOnMainThread(() =>
|
|
|
|
|
{
|
|
|
|
|
MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-02 08:52:09 +02:00
|
|
|
|
}
|
|
|
|
|
}
|