21

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

enter image description here

I'm getting it in my app – as I'm going out from my app if a user wants to login with their Facebook account.

Here's the scenario for which I don't like (want) "Back to Safari" in my app.

  1. At first launch of the app (and user not logged in).
  2. User choose Login with Facebook option.
  3. Facebook iOS SDK comes into the picture, it takes me to the Safari.
  4. I logged in and back to the app
  5. But, there's "Back to Safari"... It shouldn't be here anymore.
Hemang
  • 26,840
  • 19
  • 119
  • 186
  • 1
    Better not ask the beta OS questions here but in apple beta forum. post here - https://forums.developer.apple.com/community/pre-release/ios-9-beta – Tushar Jul 06 '15 at 14:25
  • This isn't a bug related question. I wants an answer if we can hide this programmatically or something? Because once I close (remove) Safari browser, that message will get remove. But I don't want this behaviour as I don't want my user to go back to Safari. – Hemang Jul 07 '15 at 04:42
  • 1
    Any luck in finding the solution? – Easwaramoorthy Kanagaraj Oct 05 '15 at 10:56
  • @EaswaramoorthyK, No – not yet. – Hemang Oct 05 '15 at 10:57

2 Answers2

4

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

Zia
  • 14,622
  • 7
  • 40
  • 59
0

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];
        }
       };
    
     }];
    
    }
    
Tr0yJ
  • 3,274
  • 1
  • 22
  • 30