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 URLWithString:@"http://www.facebook.com/facebook"];
[[UIApplication sharedApplication] openURL:url];
but iOS automatically launch native client (of course if it's installed) if you try to open url with in facebook domain. thanks.
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]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With