Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (void)viewDidLoad {
- (IBAction)fillUsing1Password:(id)sender {
[[OnePasswordExtension sharedExtension] fillItemIntoWebView:self.webView forViewController:self sender:sender showOnlyLogins:NO completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"Failed to fill login in webview: <%@>", error);
NSLog(@"Failed to fill into webview: <%@>", error);
}
}];
}
Expand Down
8 changes: 4 additions & 4 deletions OnePasswordExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ - (void)fillItemIntoWebView:(id)webView forViewController:(UIViewController *)vi

#ifdef __IPHONE_8_0
if ([webView isKindOfClass:[UIWebView class]]) {
[self fillLoginIntoUIWebView:webView webViewController:viewController sender:(id)sender showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error) {
[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
else if ([webView isKindOfClass:[WKWebView class]]) {
[self fillLoginIntoWKWebView:webView forViewController:viewController sender:(id)sender showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error) {
[self fillItemIntoWKWebView:webView forViewController:viewController sender:(id)sender showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error) {
if (completion) {
completion(success, error);
}
Expand Down Expand Up @@ -383,7 +383,7 @@ - (void)findLoginIn1PasswordWithURLString:(NSString *)URLString collectedPageDet
}

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0
- (void)fillLoginIntoWKWebView:(WKWebView *)webView forViewController:(UIViewController *)viewController sender:(id)sender showOnlyLogins:(BOOL)yesOrNo completion:(void (^)(BOOL success, NSError *error))completion {
- (void)fillItemIntoWKWebView:(WKWebView *)webView forViewController:(UIViewController *)viewController sender:(id)sender showOnlyLogins:(BOOL)yesOrNo completion:(void (^)(BOOL success, NSError *error))completion {
[webView evaluateJavaScript:OPWebViewCollectFieldsScript completionHandler:^(NSString *result, NSError *error) {
if (!result) {
NSLog(@"1Password Extension failed to collect web page fields: %@", error);
Expand All @@ -403,7 +403,7 @@ - (void)fillLoginIntoWKWebView:(WKWebView *)webView forViewController:(UIViewCon
}
#endif

- (void)fillLoginIntoUIWebView:(UIWebView *)webView webViewController:(UIViewController *)viewController sender:(id)sender showOnlyLogins:(BOOL)yesOrNo completion:(void (^)(BOOL success, NSError *error))completion {
- (void)fillItemIntoUIWebView:(UIWebView *)webView webViewController:(UIViewController *)viewController sender:(id)sender showOnlyLogins:(BOOL)yesOrNo completion:(void (^)(BOOL success, NSError *error))completion {
NSString *collectedPageDetails = [webView stringByEvaluatingJavaScriptFromString:OPWebViewCollectFieldsScript];
[self findLoginIn1PasswordWithURLString:webView.request.URL.absoluteString collectedPageDetails:collectedPageDetails forWebViewController:viewController sender:sender withWebView:webView showOnlyLogins:yesOrNo completion:^(BOOL success, NSError *error) {
if (completion) {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Add the `OnePasswordExtension.h`, `OnePasswordExtension.m`, and `1Password.xcass

### Use Case #1: Native App Login

In this use case we'll learn how to enable your existing users to fill their credentials into your native app's login form. If your application is using a web view to login (i.e. OAuth), you'll want to follow the web view integration steps in [Use Case #4: Web View Login Support](https://github.com/AgileBits/onepassword-app-extension#use-case-4-web-view-login-support).
In this use case we'll learn how to enable your existing users to fill their credentials into your native app's login form. If your application is using a web view to login (i.e. OAuth), you'll want to follow the web view integration steps in [Use Case #4: Web View Filling Support](https://github.com/AgileBits/onepassword-app-extension#use-case-4-web-view-filling-support).

The first step is to add a UIButton to your login page. Use an existing 1Password image from the _1Password.xcassets_ catalog so users recognize the button.

Expand Down Expand Up @@ -211,7 +211,7 @@ Adding 1Password to your change password screen is very similar to adding 1Passw
}
```

### Use Case #4: Web View Login Support
### Use Case #4: Web View Filling Support

The 1Password App Extension is not limited to filling native UIs. With just a little bit of extra effort, users can fill `UIWebView`s and `WKWebView`s within your application as well.

Expand All @@ -221,7 +221,7 @@ Simply add a button to your UI with its action assigned to this method in your w
- (IBAction)fillUsing1Password:(id)sender {
[[OnePasswordExtension sharedExtension] fillItemIntoWebView:self.webView forViewController:self sender:sender showOnlyLogins:NO completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"Failed to fill login in webview: <%@>", error);
NSLog(@"Failed to fill into webview: <%@>", error);
}
}];
}
Expand Down