To do the big platform to share the time due to account confusion, resulting in the sharing callback when the launch of another app, this time I wonder how these SDK to wake up the other apps do not start, it is not difficult to imagine, certainly with the appdelegate processing callback OpenURL about, so search for a bit to find, One application can wake up another application, just blame me for the dish, OK, now tell the unknown friend how to implement an app how to wake up another app, and let two apps communicate with each other ...
The Test engineering operation is as follows
1. Create a new App1, create a new set in the Information property list of the Info.plist file, and type the URL types set as follows
The most critical part here is the URL schemes in the array of item 0, followed by the completion of the string is the command prefix you use to communicate "Achao", the URL identifier is just an identifier, feel free to fill inand then Appdelegate. Handling overloads the following callback method
-(BOOL) Application: (UIApplication *) application Handleopenurl: (nsurl *) URL
{
if ([[URL scheme] isequaltostring:@ "Achao"])
{
NSLog (@ "%@", url);
}
return YES;
}
can see [url scheme] This command is to get the URL scheme, is the command prefix "Achao" 2. New APP2, this app nothing to operate, just to wake up App1 can, so we wrote in viewdidload this sentence
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "Achao://hello"];
"Achao" is the URL scheme in App1, I call it the command prefix (I suspect that Apple's app is loaded with a notification center-like application for unified management, and each application's URL scheme will be recorded there, For other apps to call the app, as to which application URL scheme belongs, of course, is related to the bundle identifier of the app, with the format "prefix://..." 3. We shut down the APP1,APP2, and then start the app2, found that app2 wake up after the App1, and successfully jump, we then close the APP1,APP2, then we open the App1 to monitor, found that the APP1 was launched into the
This enables wake-up and communication between two apps 4. Of course, this time you may think that it is not a lot of applications will be called by other garbage programs, after looking for data, there is a subsequentwe overload this method
-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (id) annotation
{
if ([Sourceapplication isequaltostring:@ "AC.achao.com"])
{
NSLog (@ "%@", sourceapplication); from which app (Bundle identifier)
NSLog (@ "scheme:%@", [url scheme]); URL scheme
NSLog (@ "Query:%@", [url query]); Query string access in "?..." format
return YES;
}
Else
return NO;
}
This satisfies our needs, we can use the sourceapplication to determine from which app to decide whether to wake up their own app, or through [url query] to get query string, This time we need to change the access mode of APP2 to get this parameter
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "Achao://hello?name=achao-ac"];
We can also access our App1 directly from the "Achao://hello?name=achao-ac" in Safari, this time sourceapplication is @ "Com.apple.mobilesafari"
Summary: Similar to the following method
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "http://www.baidu.com"];
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "sms://158********"];
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "tel://158********"];
[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:@ "mailto://362**** @qq. com"];
We've used a lot, and it's also estimated that a similar URL scheme is set up within the program for other applications to operate.
Perhaps I understand the mistake, welcome everyone to share together, not very grateful!
Jump between Iosapp