Navigation and communication between two apps in iOS and iosapp
Jump between apps
1. perform the following operations on the first app;
1. Add a URL types under the Information Property List in the info. plist file.
2. Open item 0 under URL types, click item 0, and change the URL identifier under item 0 to URL Schemes.
3. Click item 0 under URL Schemes and add skipOne to the end of it (skipOne is the jump ID of the first app, which is written by you here)
2. In the second app, add the following code to the place where you want to jump to the first app:
NSString *aString = @"skipOne://"; NSURL * url = [NSURL URLWithString:aString]; [[UIApplication sharedApplication]openURL:url];
3. re-run the second app and trigger the event to jump to the first app. This completes the redirection between simple apps.
Value Transfer Between apps
I. First, implement the jump function between apps.
II. The above code needs to be slightly modified.
NSString * aString = @ "skipOne ://"
In the above Code, add some information after (skipOne: //)For example:
NSString *aString =[NSString stringWithFormat:@"skipOne://username=%@&age=%@", @"xiaoxiao", @"30"];
3. In the APPDelegate of the first APP
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ NSString *urlStr = [url absoluteString]; NSLog(@"%@",urlStr); return YES;}
In this way, the urlStr string is obtained, and the string needs to be processed according to the required data.