Mutual jump between apps and mutual jump between apps
The first time I wrote a blog, I believe many people have used umeng sdks or other third-party sharing tools to jump between different apps in iOS development. The principles are the same.
The jump is implemented in four steps:
Step 1: create two projects to simulate the environment of the two apps
Step 2: Set the url of Application 2 in the second project
Step 3: Write A UIButton in the first project, and the button method is as follows:
Note that appID is added ":"
Step 4: run two projects, generate the app, and open the first project. click the button to jump to the second project.
When opening the second page, we should have the following two points of attention:
First:
1. If the second app is not started, the second app will be started and the method in the second project will be called:
-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {
// Override point for customization after application launch.
Return YES;
}
2. If the second program is started and runs in the background, this method will not be called.
Second, we can use a method to pass parameters:
// This method is called when an application is opened by another program. In this method, data transfer between two applications can be implemented.
-(BOOL) application :( UIApplication *) application openURL :( NSURL *) url sourceApplication :( NSString *) sourceApplication annotation :( id) annotation
{
NSLog (@ "% @", url );
NSLog (@ "% @", sourceApplication );
Return YES;
}