IOS app wakes up another app

Source: Internet
Author: User

The internet also has to say this piece of, feel not to speak very well. And some of the details are not clear at all. Here rewrite the relevant knowledge points.

Main content
    • What is URL Scheme?
    • Key configurations in the project
    • Precautions
What is URL Scheme?

iOSOne feature is that the app "binds" itself to a custom URL scheme that scheme launches the app from a browser or other app. Common sharing to third parties is based on Scheme the jump.

iOSit should be much easier to understand it by comparing web links URL Schemes .

    • URL, we are all very clear, http://www.apple.com is a URL , we also call it link or URL;
    • Schemes, which represents a UR position in an L-the most initial position, that is, the :// previous character. For example http://www.apple.com , this URL Schemes is http.

Based on the use of the above URL Schemes , we can easily understand that in the local application-based IOS, we can locate a Web page, as a special URL to locate an application or even a specific function of the application. Positioning the application should be part of the application, that is URL 的 Schemes , the part that opens the chief. Like texting, it'ssms:

You can understand the URL of an iOS app in a way that understands a Web page's url--, which is its URL, and makes a simple comparison between Apple's website and iOS:

Web page (apple) IOS app ()
Home/Open App Http://www.apple.com weixin://
Sub-page/specific features http://www.apple.com/mac/(Mac page) Weixin://dl/moments (Circle of Friends)

So much for the basic conceptual nature.

The key configuration in the project is in the project InfoOf Url TypeIn the configuration ( evoked End

Url Type, which indicates which prefix URLs can be opened instead of opening apps that start with those prefixes.


    • Description
      • URL identifier is just an identifier, feel free to fill in, suggested to write: com.*.* reverse Domain name method to ensure that the name of uniqueness.
      • URL scheme is the command prefix you use to communicate, to locate an application.
In PlistConfiguration in Files
    • Note: URL Schemes is an array that allows the app to define multiple URL schemes . Received to evoke how to handle

In the proxy method to - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation determine the source of arousal, according to the parameters carried by source app Url different operations. such as jumping to the development of the page, related to the logical processing and so on.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url         sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSLog(@"Calling Application Bundle ID: %@", sourceApplication); NSLog(@"URL scheme:%@", [url scheme]); NSLog(@"URL query: %@", [url query]); // Customer Code return YES; }

The above configuration is configured in the evoked application.

Evoke end

In general, the caller can invoke appDelegate the proxy method directly to wake up other applications.

- (void) awakeotherapp{nsstring *customurl = @ "otherapp://"; if ([[uiapplication Sharedapplication] CanOpenURL:[nsurl Urlwithstring:customurl]) {[uiapplication Sharedapplication] Openurl:[nsurl Urlwithstring:customurl]]; } else {uialertview *alert = [[@ "URL error" Message:[ NSString stringWithFormat: @ "No custom URL defined for%@", CustomURL] Delegate:self cancelbuttontitle:@" OK "otherbuttontitles: nil]; [Alert show]; } }
    • It's important to note that in the iOS9 future, the evoked side needs to be configured

LSApplicationQueriesSchemes.iOS9 After the need, and iOS9 then improve app the security, need to give a similar white list of things, in the white list can be opened app . Otherwise, the error: -canopenurl:failed for URL: "openapptest://mark?id=007"-Error: "The" This app was not the allowed to the query for scheme O Penapptest "


Precautions

The above method can be used to wake up other applications and briefly summarize some of the considerations.

    1. URL Scheme is actually the only sign of an app app. Use it to make sure that the app is open.
    2. Be sure to distinguish which configurations are configured, Wake up, and wake up.
    3. After iOS9, you need to add to the evoke side LSApplicationQueriesSchemes .
    4. There is another problem that is not resolved, how to go back to the wake-up application interface. This need to refer to the official XCallbackURL . I heard it's a little complicated, so I'll see.



Text/paper Jane (Jane book author)
Original link: http://www.jianshu.com/p/7a308f5b89fc
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".

IOS app wakes up another app

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.