agilebits / onepassword-app-extension

1Password Extension for iOS Apps
2.58k stars 311 forks source link

iOS 10.1 share sheet not appearing using WKWebview #355

Closed mikeKane closed 7 years ago

mikeKane commented 7 years ago

I am attempting to implement the onepassword extension to fill in a WKWebview on iOS10.1, however the code provided does not call the share sheet to appear. The extension says its available and I'm using cocoapads to install.

I made a test project just to be sure there were no other factors. I loaded the test project with the same code using a UIWebview and it worked great, when I switched the UIWebView to a WKWebview it stopped working. Any idea's?

Xcode 8.1 Min Target iOS 9 Device 7+

Test Project Provided onepasswordTest.zip

Update on debugging. It is showing the below method does not exist:

[self fillItemIntoWKWebView:webView forViewController:viewController sender:(id)sender showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error)]

If I change the the method:

[[OnePasswordExtension sharedExtension] fillItemIntoWebView:_wkWebView forViewController:self sender:sender showOnlyLogins:YES completion:^(BOOL success, NSError *error)]

to the code below and manually add:

[self fillItemIntoWKWebView:webView forViewController:viewController sender:(id)sender showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error)]

the share sheet finally appears.

pragma mark - Web View filling Support

//#ifdef IPHONE_8_0 if ([webView isKindOfClass:[UIWebView class]]) { [self fillItemIntoUIWebView:webView webViewController:viewController sender:(id)sender showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error) { if (completion) { completion(success, error); } }]; } //#if IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 || ONE_PASSWORD_EXTENSION_ENABLE_WK_WEB_VIEW else if ([webView isKindOfClass:[WKWebView class]]) { [self fillItemIntoWKWebView:webView forViewController:viewController sender:(id)sender showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error) { if (completion) { completion(success, error); } }]; } // #endif //#endif }

gks commented 7 years ago

Hi @mikeKane

I see you closed this, were you able to figure out what was happening or do you still need assistance?

mikeKane commented 7 years ago

@gks Thanks for responding. Using cocoapods this was not fixed. However manually dragging the .h and .m from the readme worked.

I do have some more questions but did not want to flood the issues area.

  1. We are a VPN using localhost. Is there anyway to distinguish our app from other apps that use localhost.
  2. The email/username portion is working great however the password box will not fill in. Im attempting to debug this but not coming up with anything noteworthy. Is there anything to look out for?
gks commented 7 years ago

Hi @mikeKane No worries, happy to help here since this is already started. Or you can email in if you prefer: support+appex@agilebits.com

  1. I assume you're using "localhost" for the URL then? If so, nope, we only filter by the URL provided us. The way around this would be to provide a real Cocoa interface and combine with use case #1 in which you could provide your actual website URL. This would allow you to have any login items created to have the URL of your site, and then when you request that URL you'll get the results that are only yours.
  2. Naming the field and using the id to name the field would be a clue to our filling system. Odds are it's not seeing it as a password field. Or if you're doing anything fancy with the field that would do it. Third possibility I can think of is that maybe you've got 2 password fields, one hidden and one visible? It's possible we're filling into the hidden one.
mikeKane commented 7 years ago

I will change to email. Thank you very much so far.