【问题标题】:Is there a way to hide "Back to Safari" from status bar in iOS9?有没有办法从 iOS9 的状态栏中隐藏“返回 Safari”?
【发布时间】:2015-12-06 07:37:39
【问题描述】:

如何以编程方式隐藏此

我在我的应用程序中获取它 - 如果用户想使用他们的 Facebook 帐户登录,我将从我的应用程序中退出。

这是我不喜欢(想要)在我的应用中“返回 Safari”的场景。

  1. 首次启动应用时(用户未登录)。
  2. 用户选择使用 Facebook 登录选项。
  3. Facebook iOS SDK 出现了,它把我带到了 Safari。
  4. 我登录并返回应用程序
  5. 但是,有“返回 Safari”……它不应该再出现了。

【问题讨论】:

  • 最好不要在这里问测试版操作系统问题,而是在苹果测试版论坛上问。在这里发帖 - forums.developer.apple.com/community/pre-release/ios-9-beta
  • 这不是一个与错误相关的问题。如果我们可以以编程方式隐藏这个问题,我想要一个答案?因为一旦我关闭(删除)Safari 浏览器,该消息就会被删除。但我不希望这种行为,因为我不希望我的用户返回 Safari。
  • 找到解决方案的运气好吗?
  • @EaswaramoorthyK,不——还没有。

标签: ios mobile-safari ios9 uistatusbar applinks


【解决方案1】:

不,没有 API 可以让您执行此操作。

【讨论】:

  • 我们至少可以覆盖该操作吗?
  • 太好了,我有打开其他应用程序并返回到我的逻辑,这个按钮搞乱了我的整个逻辑 - 我不明白为什么它可以被禁用?
  • 我找不到任何文档。我认为我们根本不能碰它。
【解决方案2】:

您可以通过转发到网站并转发回您的应用来实现此目的。以下步骤允许您在状态栏中隐藏“返回 Safari”,MyApp 是示例应用名称:

  1. 将您的应用程序 URL Scheme 添加到 Info.plist

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>myapp</string>
    </array>
    
  2. 在网站上设置自定义 URL 转发(例如 http://example.com/myapp

    _redirect_rule_from /myapp
    _redirect_rule_to myapp://
    
  3. 在您的授权方法中,关闭您在第 2 步中创建的转发

    - (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];
        }
       };
    
     }];
    
    }
    

【讨论】:

    猜你喜欢
    • 2014-09-30
    • 1970-01-01
    • 2020-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多