Open Facebook url in Safari instead of native app

后端 未结 2 1766
面向向阳花
面向向阳花 2021-01-02 07:05

is there any way to open Facebook url (ex. http://www.facebook.com/facebook) in Safari instead of native app? I\'m tried to do this:

NSURL *url = [NSURL URLW         


        
相关标签:
2条回答
  • 2021-01-02 07:39

    Copy link to the messenger app and send to yourself. Open the link on messenger app and click on share and will apear open with facebook app

    0 讨论(0)
  • 2021-01-02 07:41

    Ok, I think I found answer, you must replace "www.facebook.com" with "facebook.com" in url.

    Something like this:

    NSString *facebookUrlString = @"http://www.facebook.com/facebook";
    
    if ([[facebookUrlString pathComponents] count] > 0) {
        if ([[facebookUrlString pathComponents][1] isEqualToString:@"www.facebook.com"]) {
            NSMutableArray *pathComponents = [[facebookUrlString pathComponents] mutableCopy];
            [pathComponents replaceObjectAtIndex:1 withObject:@"facebook.com"];
            facebookUrlString = [NSString pathWithComponents:pathComponents];
        }
    }
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:facebookUrlString]];
    
    0 讨论(0)
提交回复
热议问题