Skip to content

Instantly share code, notes, and snippets.

@kwylez
Created August 12, 2015 17:17
Show Gist options
  • Save kwylez/f19e6d6088fc2f10ea45 to your computer and use it in GitHub Desktop.
Save kwylez/f19e6d6088fc2f10ea45 to your computer and use it in GitHub Desktop.
After the "OAuth dance" is complete the request is never sent back to the app. I didn't have this happen with UIWebViews.
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
RTVLog(@"decidePolicyForNavigationAction %@", navigationAction);
if (navigationAction.navigationType == WKNavigationTypeOther) {
NSURL *url = navigationAction.request.URL;
UIApplication *app = [UIApplication sharedApplication];
if ([[url scheme] isEqualToString:RabbleURLScheme]) {
if ([app canOpenURL:url]) {
[app openURL:url];
}
}
} else if (navigationAction.navigationType == WKNavigationTypeLinkActivated) {
NSString *url = navigationAction.request.URL.absoluteString;
self.goBackButtonItem.enabled = [url rangeOfString:__loginURL].location == NSNotFound ? YES : NO;
self.goBackButtonItem.title = NSLocalizedString(@"Back", nil);
}
decisionHandler(WKNavigationActionPolicyAllow);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment