iOS Facebook App browser - force link to open in Safari

前端 未结 2 658
梦毁少年i
梦毁少年i 2020-12-19 03:04

The Facebook App has it\'s own browser (using the UIWebView for iOS apps) but it has a few limitations. We need certain links on our site to be sure to be viewed with Safari

相关标签:
2条回答
  • 2020-12-19 03:37

    well iOS uses something called an URL Scheme so you might be able to try to use that. It works with native code...

    NSString *stringURL = @"http://fakewebsite.example.com/";
    NSURL *url = [NSURL URLWithString:stringURL];
    [[UIApplication sharedApplication] openURL:url];
    

    not sure if it is possible to do something similar in javascript

    0 讨论(0)
  • 2020-12-19 03:51

    There might not be a way to automate this but you should be able to detect it and handle it more gracefully. Facebook adds some extras to the User agent string so you could sniff for some of the FB.. info bits:

    Mozilla/5.0 (iPad; U; CPU iPhone OS 5_1_1 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.1.1;FBBV/4110.0;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/5.1.1;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US;FBSF/1.0]
    

    There seems to be some people trying to figure out what they mean, but regardless they tell you that you're within that facebook web frame.

    Sniffing (js or backend) for one of these would allow you to load the page differently or at least display an explanation and instructions to open it in safari. Still not automatic but you can at least detect the situation and have a documented manual solution.

    0 讨论(0)
提交回复
热议问题