diff --git a/src/iOS.Extension/ActionViewController.cs b/src/iOS.Extension/ActionViewController.cs index cb79c549f..9f00c4d04 100644 --- a/src/iOS.Extension/ActionViewController.cs +++ b/src/iOS.Extension/ActionViewController.cs @@ -17,6 +17,14 @@ namespace Bit.iOS.Extension { public partial class ActionViewController : UIViewController { + private const string AppExtensionVersionNumberKey = "version_number"; + private const string AppExtensionUrlStringKey = "url_string"; + private const string UTTypeAppExtensionFindLoginAction = "org.appextension.find-login-action"; + private const string UTTypeAppExtensionSaveLoginAction = "org.appextension.save-login-action"; + private const string UTTypeAppExtensionChangePasswordAction = "org.appextension.change-password-action"; + private const string UTTypeAppExtensionFillWebViewAction = "org.appextension.fill-webview-action"; + private const string UTTypeAppExtensionFillBrowserAction = "org.appextension.fill-browser-action"; + public ActionViewController() : base("ActionViewController", null) { if(!Resolver.IsSet) @@ -50,11 +58,11 @@ namespace Bit.iOS.Extension .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()); - // Other - //.RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager()) - //.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) - //.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager()) - //.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager()); + // Other + //.RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager()) + //.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) + //.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager()) + //.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager()); Resolver.SetResolver(new UnityResolver(container)); } @@ -97,34 +105,73 @@ namespace Bit.iOS.Extension { foreach(var itemProvider in item.Attachments) { - if(!itemProvider.HasItemConformingTo(UTType.PropertyList)) + if(ProcessWebUrlProvider(itemProvider)) { - continue; + break; } - - itemProvider.LoadItem(UTType.PropertyList, null, (NSObject list, NSError error) => + else if(ProcessFindLoginProvider(itemProvider)) { - if(list == null) - { - return; - } - - var dict = list as NSDictionary; - var result = dict[NSJavaScriptExtension.PreprocessingResultsKey]; - if(result == null) - { - return; - } - - HtmlContent = result.ValueForKey(new NSString("htmlContent")) as NSString; - BaseUri = new Uri(result.ValueForKey(new NSString("baseUri")) as NSString); - Url = new Uri(result.ValueForKey(new NSString("url")) as NSString); - }); - - break; + break; + } } } } + private bool ProcessWebUrlProvider(NSItemProvider itemProvider) + { + if(!itemProvider.HasItemConformingTo(UTType.PropertyList)) + { + return false; + } + + itemProvider.LoadItem(UTType.PropertyList, null, (NSObject list, NSError error) => + { + if(list == null) + { + return; + } + + var dict = list as NSDictionary; + var result = dict[NSJavaScriptExtension.PreprocessingResultsKey]; + if(result == null) + { + return; + } + + HtmlContent = result.ValueForKey(new NSString("htmlContent")) as NSString; + BaseUri = new Uri(result.ValueForKey(new NSString("baseUri")) as NSString); + Url = new Uri(result.ValueForKey(new NSString("url")) as NSString); + }); + + return true; + } + + private bool ProcessFindLoginProvider(NSItemProvider itemProvider) + { + if(!itemProvider.HasItemConformingTo(UTTypeAppExtensionFindLoginAction)) + { + return false; + } + + itemProvider.LoadItem(UTTypeAppExtensionFindLoginAction, null, (NSObject list, NSError error) => + { + if(list == null) + { + return; + } + + var dict = list as NSDictionary; + var version = dict[AppExtensionVersionNumberKey] as NSNumber; + var url = dict[AppExtensionUrlStringKey] as NSString; + if(url == null) + { + return; + } + + Url = new Uri(url); + }); + + return true; + } } } \ No newline at end of file diff --git a/src/iOS.Extension/Info.plist b/src/iOS.Extension/Info.plist index d14a48ce2..b07c9fd51 100644 --- a/src/iOS.Extension/Info.plist +++ b/src/iOS.Extension/Info.plist @@ -29,18 +29,20 @@ NSExtensionJavaScriptPreprocessingFile extension NSExtensionActivationRule - - NSExtensionActivationSupportsFileWithMaxCount - 0 - NSExtensionActivationSupportsImageWithMaxCount - 0 - NSExtensionActivationSupportsMovieWithMaxCount - 0 - NSExtensionActivationSupportsText - - NSExtensionActivationSupportsWebURLWithMaxCount - 1 - + SUBQUERY ( + extensionItems, + $extensionItem, + SUBQUERY ( + $extensionItem.attachments, + $attachment, + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" + || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.find-login-action" + || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.save-login-action" + || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.change-password-action" + || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.fill-webview-action" + || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.fill-browser-action" + ).@count == $extensionItem.attachments.@count + ).@count == 1 NSExtensionPointName com.apple.ui-services NSExtensionPointVersion diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 51e4333be..db4588e0a 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -107,6 +107,11 @@ namespace Bit.iOS Debug.WriteLine("WillEnterForeground"); } + public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation) + { + return true; + } + private void SendLockMessage() { MessagingCenter.Send(Xamarin.Forms.Application.Current, "Lock", false); diff --git a/src/iOS/Info.plist b/src/iOS/Info.plist index 868928fd2..784efb9bb 100644 --- a/src/iOS/Info.plist +++ b/src/iOS/Info.plist @@ -22,7 +22,7 @@ UIInterfaceOrientationLandscapeRight MinimumOSVersion - 9.3 + 9.0 CFBundleDisplayName bitwarden CFBundleIdentifier @@ -57,8 +57,20 @@ UIMainStoryboardFile~ipad LaunchScreen UIStatusBarStyle -+ UIStatusBarStyleLightContent -+ UIViewControllerBasedStatusBarAppearance -+ + UIStatusBarStyleLightContent + UIViewControllerBasedStatusBarAppearance + + CFBundleURLTypes + + + CFBundleURLSchemes + + bitwarden + org-appextension-feature-password-management + + CFBundleURLName + com.bitwarden.vault.url + +