Launch other apps in a OpenURL way

Source: Internet
Author: User

Assuming there are two apps, the project name is Samplea and Sampleb, you need to click a button in Samplea to start the Sampleb and pass a string. The specific implementation steps are as follows:

1. Add a URL schemes to the Info.plist file in Sampleb and specify a string that is the name of the link that invokes the app:

2. Execute the following code in the Samplea button click Operation:

-(Ibaction) Openclickhandler: (ID) sender{    [[uiapplication sharedapplication] Openurl:[nsurl URLWithString:@ "myapp23://time_is_money"];}

3. In the Appdelegate class of Sampleb, invoke the URL that the system event handler passes over:

-(BOOL) Application: (UIApplication *) application Handleopenurl: (Nsurl *) url{    *strinfo = [[url host] Stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding];         *alertview = [[Uialertview alloc] Initwithtitle:@ " hint "delegate: Nil Cancelbuttontitle:@ "OK"  Otherbuttontitles:nil];    [Alertview show];         return YES;}

Summarize:

1. When launching other apps by OpenURL, the address format is @ "URL scheme://url identifier", where URL identifier is optional.

2. URL identifier cannot contain spaces and question marks.

3. Apple does not support this practice and is used with caution in actual product development.

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.