有没有办法在iOS9的状态栏中隐藏“回到Safari”?
如何隐藏这个<以编程方式从状态栏返回到Safari?
我在我的应用程序中得到它 – 如果用户想用他们的Facebook帐户login,我会从我的应用程序出去。
这是我不喜欢(想)在我的应用程序“回到Safari”的情况。
- 首先启动的应用程序(和用户没有login)。
- 用户select使用Facebook选项login。
- Facebook的iOS SDK进入了图片,它把我带到Safari。
- 我login并返回到应用程序
- 但是,有“回到Safari”…它不应该在这里了。
不,没有API可以让你做到这一点。
你可以通过转发到一个网站,转发回你的应用程序来实现这一点。 以下步骤允许您隐藏状态栏中的“返回到Safari”,MyApp是示例应用程序名称:
-
将您的应用程序URL Scheme添加到Info.plist
<key>LSApplicationQueriesSchemes</key> <array> <string>myapp</string> </array>
-
在网站上设置自定义url(例如http://example.com/myapp )
_redirect_rule_from /myapp _redirect_rule_to myapp://
-
在您的授权方法中,closures您在步骤2中创build的前进
- (void)willLoginWithFacebook { __weak __typeof(self) weakSelf = self; [self.view setUserInteractionEnabled:NO]; [self.sessionManager authenticateViaFacebookWithCompletion:^(NSString *token, NSSet *grantedPermissions, NSError *error) { if (error) { if (error.code != myappErrorCodeCancelled) { [weakSelf.rootViewController presentError:error]; } } else { [weakSelf authorizeWithFacebookToken:token]; NSString *customURL = @"myapp://"; if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]]) { NSString *stringURL = @"http://example.com/myapp"; NSURL *url = [NSURL URLWithString:stringURL]; [[UIApplication sharedApplication] openURL:url]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL error" message:[NSString stringWithFormat: @"No custom URL defined for %@", customURL] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; } }; }]; }