我正在尝试通过UIWebView对facebook sdk进行授权,但即使我在stackoverflow上执行了所有注释和值切换建议后,它仍然继续打开safari。还有什么我应该注意的吗?我只使用一个视图使用ARC启用测试项目。
我将trySafariAuth设置为NO
BOOL didOpenOtherApp = NO;
trySafariAuth = NO;
UIDevice *device = [UIDevice currentDevice];
if ([device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported]) {
if (tryFBAppAuth) {
NSString *scheme = kFBAppAuthURLScheme;
if (_urlSchemeSuffix) {
scheme = [scheme stringByAppendingString:@"2"];
}
NSString *urlPrefix = [NSString stringWithFormat:@"%@://%@", scheme, kFBAppAuthURLPath];
NSString *fbAppUrl = [FBRequest serializeURL:urlPrefix params:params];
didOpenOtherApp = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fbAppUrl]];
}
if (trySafariAuth && !didOpenOtherApp) {
NSString *nextUrl = [self getOwnBaseUrl];
[params setValue:nextUrl forKey:@"redirect_uri"];
NSString *fbAppUrl = [FBRequest serializeURL:loginDialogURL params:params];
didOpenOtherApp = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fbAppUrl]];
}
}
// If single sign-on failed, open an inline login dialog. This will require the user to
// enter his or her credentials.
if (!didOpenOtherApp) {
[_loginDialog release];
_loginDialog = [[FBLoginDialog alloc] initWithURL:loginDialogURL
loginParams:params
delegate:self];
[_loginDialog show];
}
我也改变了:
- (void)authorize:(NSArray *)permissions {
self.permissions = permissions;
[self authorizeWithFBAppAuth:YES safariAuth:NO];
}