First of all, this function should have been contacted.
For example, if you download an ebook and then choose to open it, you may see the Reading app already installed on your phone.
Or, your QQ has received a file, you can also choose the local app to open.
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.
If you want your app to be called, you can set this up.
In the XXXX info.plist file, add the following properties
Similar to this:
Note that the URL schemes is required here, and the URL identifier optional.
In addition, the URL schemes recommendation is lowercase, because when the data is received, it is case-insensitive and is lowercase.
The specified format is URL schemes://url identifier
After that, you need to add 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 wrote a demonstration of whether to open the URL of the app, and if so, pop up a warning box to show the data coming in.
Of course, what to do with the data, it's up to you.
Third-party applications can then be called directly to open it.
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:
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