"IOS" app calls between

Source: Internet
Author: User

Call steps between iOS apps: First, invoke the app you've developed

1) in the plist file, register the external interface

In Xcode group&files, expand the resources selection <app>info.plist

Right-click the Information property list and select the URL from the list types

Right-click the Add row to append an object (item) Right-click on the item add row

Select a URL from the list schemes and then right-click to add an object (ITEM1)

Set the Item1 value to: MyApp

This myapp is an external interface, which other applications can use to invoke the application

Plist as shown:

2) Calling method

In the application where you need to invoke the external interface registered above, add the following code:

Nsurl *url = [Nsurl urlwithstring:@ "MyApp:"];

[[UIApplication sharedapplication] openurl:url];

With these two steps, you can allow users to open your other apps in your app

Second, call the app that comes with iOS

This is the application that calls itself, explains how to invoke the problem between your own applications, and today introduces how to call an app that comes with iOS

First, call the App Store interface method

In the actual development, often to recommend their own other applications and recommend their own fee software, then we need to connect directly to the App store's corresponding page in the program.

The practical approach is simple, using the OpenURL method of the UIApplication class:

[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:@ "The corresponding connection of the program]];

Ii. methods for invoking other applications

1) call to bring your own mail?

[[Uiapplicationsharedapplication] openurl:[nsurlurlwithstring:@ "mailto://[email protected]"];

2) Call telephone phone?

[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "tel://8008808888"];?

3) Call SMS

? [[Uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "sms://800888"];?

4) Call your own browser safari

? [[Uiapplicationsharedapplication] openurl:[nsurlurlwithstring:@ "http://www.hzlzh.com"];

5) Call Remote

? [[Uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "REMOTE://FFF"];

The above is the most basic statement, there is no processing process.

such as: Call phone can pass the number, call SMS can only set the number, cannot initialize the SMS content.


Register a URL for your application, and then use "other apps" or "Safari" to open a "registered URL" app. First give yourself a program to register a URL, in the project plist file to add the following, see the following table:

(URL types start)

Then compile and run the program, after the simulator run, do not stop the project to run, but directly press the home button on the emulator, when the application back to the background. Open Safari, enter Todolist://com.acme.todolist, click Go, and you can reopen the app. Where Todolist://com.acme.todolist is able to write by itself in the form of a random (format: xxx://xxx).

In addition, the program starts no longer to call didfinishlaunchingwithoptions, in fact, should not call this method.

The order in which the application delegate method is invoked is:

-[appdelegate Applicationwillenterforeground:]

-[appdelegate application:handleopenurl:]//is here to deal with some of the things that are done in this way after startup.

-[appdelegate Applicationdidbecomeactive:]

Although the iphone does not allow two applications to run at the same time, we can launch another application from within our own application and share data between applications. We can use the UIApplication class's OpenURL: method to start another application from one application. For example, to open the Google home page in the Safari app, we could write the following code:
Nsurl *url = [Nsurl urlwithstring:@ "http://google.com"];

[[UIApplication sharedapplication] openurl:url];

The http://section here is called the URL scheme (URL scheme), which represents the application you want to load.
There are several URL schemes for native iphone applications, and you can launch them in a similar way.
For example, to start the mail application (shown in 3-15), we can use:
Nsurl *url = [Nsurl urlwithstring:@ "Mailto:[email protected]= test"];

[[UIApplication sharedapplication] openurl:url];

To start the SMS application, we can write the following code:
Nsurl *url = [Nsurl urlwithstring:-"sms:555-1234"];

[[UIApplication sharedapplication]-penurl:url];

To dial a phone number, we can use the following code:
Nsurl *url=[nsurl urlwithstring:@ "tel://555-1234"];

[[UIApplication sharedapplication] openurl:url];

To launch the Maps app to find a pizzeria (shown in 3-16), we use the following code:
Nsurl *url = [Nsurl urlwithstring:@ "Http://maps.google.com/maps?q=pizza"];

[[UIApplication sharedapplication] openurl:url];

We can also use the URL scheme to launch our own applications:
Use a custom URL scheme to launch the application:
1) Create a new view-based application and save it as urlschemeexample.
2) in the Xcode Groups & Files Panel, expand the Resource section and select the <app>-info.plist file.
3) Right click on the Information Property list key and click the add arrow to select "URL types" from the list (3-17).
4) Expand Item 1, right-click the URL identifier, and select Add arrow again to select the URL from the list schemes (3-18).

Figure 3-17 Adding a URL type
Figure 3-18 Adding a URL scheme
Figure 3-19 Setting the name of the URL scheme

5) Select item 1 and set its value to MyApplication (3-19).
6) Open Urlschemeexampleview controller.m, uncomment the Viewdidload method, and write the following code:

[Self.view Setbackgroundcolor:[uicolor Redcolor];

Build and run the application. You should see a red screen with no content. The application will not do anything at this time, but by running it (the app installed on the iphone or emulator), we just register the URL scheme (myapplication) created in step 5.
8) We can launch the application from a different application using the following code:
Nsurl *url = [Nsurl urlwithstring:@ "MyApplication:"];

[[UIApplication sharedapplication] openurl:url];

"IOS" app calls between

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.