IOS --- jump between apps
In iOS devices, the interaction between apps is mainly achieved through the openURL of UIApplication.
Take Instagram (SDK not provided) as an example:
//// ViewController.m#import ViewController.h@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; NSString *username = @icetime017; [self openUserPage:username];}- (BOOL)isInstagramInstalled { NSURL *instagramURL = [NSURL URLWithString:@instagram://location?id=1]; return [[UIApplication sharedApplication] canOpenURL:instagramURL];}- (void)openUserPage:(NSString *)username { NSURL *fansPageURL; if ([self isInstagramInstalled]) { fansPageURL = [NSURL URLWithString:[NSString stringWithFormat:@instagram://user?username=%@, username]]; } else { fansPageURL = [NSURL URLWithString:[NSString stringWithFormat:@http://instagram.com/%@, username]]; } [[UIApplication sharedApplication] openURL:fansPageURL];}@end
That is:
Use [[UIApplication sharedApplication] canOpenURL: instagramURL]; To determine whether the APP has been installed,
Use [[UIApplication sharedApplication] openURL: fansPageURL]; To open the APP. If it is not installed, the corresponding page is opened in safari by default.