我有OAuthStarterKit
运行和工作的链接(网络视图很慢!)基本视图带有一些基本代码,用于检测弹出式网络视图何时关闭(参见以下函数)。
问题是,当用户看到 Linkedin 登录页面时,它无法检测到用户何时单击取消按钮。网址:https://www.linkedin.com/uas/oauth/www.core.me
。
我将如何过滤“已取消”页面?
过滤/关闭代码
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
addressBar.text = urlString;
[activityIndicator startAnimating];
BOOL requestForCallbackURL = ([urlString rangeOfString:linkedInCallbackURL].location != NSNotFound);
if ( requestForCallbackURL )
{
BOOL userAllowedAccess = ([urlString rangeOfString:@"user_refused"].location == NSNotFound);
if ( userAllowedAccess )
{
[self.requestToken setVerifierWithUrl:url];
[self accessTokenFromProvider];
}
else
{
// User refused to allow our app access
// Notify parent and close this view
[[NSNotificationCenter defaultCenter]
postNotificationName:@"loginViewDidFinish"
object:self
userInfo:nil];
[self dismissModalViewControllerAnimated:YES];
}
}
else
{
// Case (a) or (b), so ignore it
}
return YES;
}