iOS Dev-open third-party apps and pass values within apps

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.