First of all, this function should have been contacted.
For example, when you download an ebook and then choose to open it, you may see the Reading app already installed on your phone.
Or, if your QQ receives a file, you can also select a local app to open it.
So how does this function come true?
In simple terms. is to invoke the URL to enable third-party applications.
First, the application that is opened needs to provide this function, that is, it needs to register a URL schemes for use by a third party.
Suppose you want your app to be called and you can set that up.
In the XXXX info.plist file, add for example the following attributes
Similar to this:
Note that the URL schemes is required here, and the URL identifier optional.
In addition, the URL schemes recommendations are lowercase, since the data is received later, the case is not differentiated between uppercase and lowercase, are converted to lowercase.
The specified format is URL schemes://url identifier
After that, you need to include the following code in the APPDELEGATE.M to handle the processing that was made after the request was received
Processing URL request-(BOOL) Application: (UIApplication *) application Handleopenurl: (Nsurl *) url{ NSLog (@ "%@", url); if ([[URL scheme] isequaltostring:@ "Myurltest"]) { //process link nsstring *text = [[URL host] Stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]; Uialertview *myalert = [[Uialertview alloc]initwithtitle:@ "New Message" Message:text delegate:self cancelButtonTitle:@ "yes" Otherbuttontitles:nil]; [Myalert show]; return YES; } return NO;}
Here I've written a demonstration of whether to open the URL of the app, assuming that it pops up a warning box that shows the data coming in.
Of course, what to do with the data, it's up to you.
Third-party applications can then be called to open it directly.
Let's do a simple demonstration by using Safari to open it directly.
Enter Myurltest://hello here to indicate the URL of the open app schemes is myurltest, and the incoming data is Hello
Of course, open in the app, we can use the following methods, for example:
Nsurl *url = [Nsurl urlwithstring:@ "myurltest:"];[ [UIApplication sharedapplication] openurl:url];
Also, by the way, mark the URL of some known app schemes
What do you know about the fun and fun IOS URL schemes?
iOS Dev-open third-party apps and pass values within apps