App call-Compare complete:D

Source: Internet
Author: User
Tags rfc home screen reverse dns

First, call the system application

1, 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    "]];  1, call the other application Method 1) Call the 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"];

   Second, call your own development application   1) in the plist file, register the external interface      in Xcode group&files, expand the resources selection <app>info.plist     Right-click Information Property list, then select URL from list types      right click Add row adds an object (item) Right-click on item add row       Select URL from list  schemes then right click to add an object (item1)      Set the Item1 value to:myapp     This myapp is the external interface, which other applications can use to invoke the application     plist as shown:    2) Call method      in the application where you need to invoke the external interface, 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.    If you add parameters, it's best to write @ "myapp://...", just like HTTP request "http" to "MyApp".     3) Handling URL requests   Application delegates handle URL requests that are passed to the application in the Application:handleopenurl: method. If you have registered a custom URL pattern for your application, be sure to implement this method in the delegate.   The protocol that is based on the custom pattern URL is understood by the application that requests the service. The URL contains some information that the application expects to receive in registered mode, which is the program that processes theOr in response to a URL request. The Nsurl object that is passed to the Application:handleopenurl: method represents the URL in the cocoa touch frame. Nsurl follows the RFC 1808 specification, which contains methods that return the individual URL features defined by RFC 1808, including user names, passwords, requests, fragments, and parameter strings. The "protocol" that corresponds to the custom mode you register can use these URL features to deliver various information.   In Listing 1-2 shows the Application:handleopenurl: method implementation, the incoming URL object in its request and fragment section with the specific application information. The application delegate extracts this information-in this case, the name and expiration date of a to-do task-and creates the application's model object based on that information.  [plain]
-(BOOL) Application: (UIApplication *) application Handleopenurl: (nsurl *) URL {if ([[URL scheme] isequaltostring:@ "Mya      PP "]) {//process link return YES;  } return NO; }-(BOOL) Application: (UIApplication *) application Handleopenurl: (nsurl *) URL {if ([[URL scheme] isequaltostring:@ "M    Yapp "]) {//process link return YES; } return NO; Be sure to verify the incoming URL input. If you would like to know how to avoid the issue of URL handling, see the validation input section in the Security Coding Guide documentation. If you want to know the URL pattern defined by Apple, see the URL pattern reference for Apple the second method of handling URL requests [CPP]
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions   {    //called by other apps       Nsurl *url = [launchoptions objectforkey: Uiapplicationlaunchoptionsurlkey];      if (URL) {//make a corresponding decision           if ([[URL scheme] isequaltostring:@ "MyApp" ]) {            //process links          }      }      Self.window = [[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease];     //Override point for customization after application launch.       Self.viewcontroller = [[[Viewcontroller alloc] initwithnibname:@ "Viewcontroller" Bundle:nil ] Autorelease];      Self.window.rootViewController = Self.viewcontroller;      [Self.window makekeyandvisible];      return YES;  }   -(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{    //calls by other applications     Nsurl *url = [Launchoptions objectforkey:uiapplicationlaunchoptionsurlkey];    if (URL) {//Make appropriate judgments         if ([[[URL scheme] isequaltostring:@ "MyApp"]) {      &N Bsp    /processing links        }   }    Self.window = [[[UIWindow alloc] Initwithfra Me:[[uiscreen Mainscreen] bounds] autorelease];   //Override point for customization after application launch .    Self.viewcontroller = [[[Viewcontroller alloc] initwithnibname:@ "Viewcontroller" Bundle:nil] autorelease];    Self.window.rootViewController = self.viewcontroller;    [Self.window makekeyandvisible];    return YES;} Description: The IOS program always calls Application:didfinishlaunchingwithoptions when it starts: The second parameter launchoptions is an object of type Nsdictionary, which stores the reason for this program to start. Possible key values in  launchoptions see UIApplication class Reference's launch Options keys section.   If the user launches directly, lauchoptions No data, if the other application through OpenURL: Start, then uiapplicationlaunchoptionsurlkey corresponding object is the boot URL (nsurl), Uiapplicationlaunchoptionssourceapplicationkey the bundle ID (nsstring) of the source application that corresponds to the start, and if it is initiated by local notification, The uiapplicationlaunchoptionslocalnotificationkey corresponds to the local notification object (Uilocalnotification) to start the application, and if it is started by a remote notification, The uiapplicationlaunchoptionsremotenotificationkey corresponds to the remote notification information userinfo (nsdictionary) that launches the application. and other keys and Uiapplicationlaunchoptionsannotationkey,uiapplicationlaunchoptionslocationkey, Uiapplicationlaunchoptionsnewsstanddownloadskey. Reference: http://blog.csdn.net/tiger119/article/details/7949004  4). Quick test External call 1. Go back to the home screen and launch Safari (on the iphone emulator , select the Hardware->home command on the menu to go back to the home screen). 2. In the address bar of safari, type the URL using the custom mode, "MyApp:", with the argument "myapp://..." 3. Verify that your application starts and that the application delegate receives application: Handleopenurl: Message.   Third, the official principles of interpretation    and other applications for communication if an application supports some known types of URLs, you can communicate with the program through the corresponding URL pattern. In most cases, however, a URL is simply a way to start an application and display some information about the caller. For example, for an application that manages address information, you can include an maps program in the URL that is sent to itAddress that can be processed so that the corresponding location is displayed. This level of communication creates a much more integrated environment for the user, reducing the need for the application to re-implement the functionality already implemented by other programs on the device. Apple's built-in URL pattern for HTTP, mailto, tel, and SMS also supports HTTP-based URLs that point to maps, YouTube, and ipod programs. The application can also register its own custom URL pattern. Your application can communicate with other applications by creating a Nsurl object in the correct format and then passing it to the shared UIApplication object OpenURL: Method. OpenURL: The method starts registering the application that receives the URL type and passes the URL to it. When a user eventually exits the application, your application is typically restarted, but not always. The system takes into account the user's actions in the URL handler and whether it is reasonable for the user to return to your application and then make a decision.   The following code snippet shows how a program can request a service from another program (assuming that the "todolist" in this example is a custom pattern registered by the application):  nsurl *myurl = [Nsurl urlwithstring:@] Todolist://www.acme.com? quarterly%20report#200806231300 "]; [[uiapplication Sharedapplication] openurl:myurl];   To be prompted: If your URL type contains the same pattern as Apple's definition, it starts with an apple-provided program instead of your program. If there are multiple third-party application registrations that handle the same URL pattern, it is not important to note which program is handling the URL of that type: If your URL type contains a pattern that is the same as Apple's definition, it starts with the program that Apple provides, not your program. If there are multiple third-party application registrations that handle the same URL pattern, then the URL of that type is not defined by which program processing.    If your application defines its own URL pattern, you should implement a method for processing the pattern, described in the "Implementing a Custom URL pattern" section. For system-supported URL handling, including how to handle URL formats, see the URL pattern reference for Apple.      implement a custom URL pattern you can register your application with a URL type that contains a custom pattern. A custom URL pattern is a mechanism by which third-party applications and other programs and systems interact. by Customizing the UrL mode, the application can provide its own services to other programs.      Register a custom URL pattern when registering a URL type for your application, you must specify the sub-properties of the Cfbundleurltypes property, which we have already described in the "Information attribute list" section. The Cfbundleurltypes property is an array of dictionaries in the application's Info.plist file, each of which is responsible for defining the type of URL that an application supports. Table 1-6 describes the keys and values of the Cfbundleurltypes dictionary.      table 1-6 Key and value keys   values for  cfbundleurltypes properties  CFBundleURLName  This is a string representing the abstract name of the URL type. To ensure its uniqueness, it is recommended that you use the reverse DNS-style identity, such as Com.acme.myscheme.   The URL type name provided here is a key to the localized string in the Infoplist.strings file in the localization language bun directory. Localized strings are human-identifiable URL type names, expressed in the appropriate language.  CFBundleURLSchemes  This is an array of URL patterns that represent URLs that belong to this URL type. Each pattern is a string. URLs that belong to the specified URL type have their modal components.    Figure 1-7 shows a info.plist file that is being edited with the built-in Xcode editor. In this diagram, the URL type entry in the left column is equivalent to the Cfbundleurltypes key you added directly to the Info.plist file. Similarly, the "URL identifier" and "URL schemes" portals are equivalent to the cfbundleurlname and Cfbundleurlschemes keys.   Define a custom URL pattern in the Info.plist file      you are defining the Cfbundleurltypes property to register a URL type with a custom pattern, You can test: , install, and run your application in the following ways.   Go back to the home screen, launch Safari (on the iphone emulator, select the Hardware > Home command on the menu to go back to the home screen).   In the address bar of Safari, type use custom modeThe URL.   Verify that your application is started, and that the application delegate receives the APPLICATION:HANDLEOPENURL: message.  

App call-Compare full:D

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.