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, 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

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.