Is there a way to hide “Back to Safari” from status bar in iOS9?

后端 未结 2 437
遇见更好的自我
遇见更好的自我 2020-12-10 01:28

How to hide this < Back to Safari from status bar programmatically?

\"enter

相关标签:
2条回答
  • 2020-12-10 02:04

    No, there is no API that lets you do this.

    0 讨论(0)
  • 2020-12-10 02:07

    You can achieve this by forwarding to a website with a forward back to your app. The following steps allows you to hide the 'Back to Safari' in the status bar, MyApp is the example app name:

    1. Add your application URL Scheme to the Info.plist

      <key>LSApplicationQueriesSchemes</key>
      <array>
          <string>myapp</string>
      </array>
      
    2. Setup a custom URL forward on a website (e.g. http://example.com/myapp)

      _redirect_rule_from /myapp
      _redirect_rule_to myapp://
      
    3. In your authorization method closure hit the forward you created in step 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];
          }
         };
      
       }];
      
      }
      
    0 讨论(0)
提交回复
热议问题