Use a browser to call Android or iOS applications

Source: Internet
Author: User

When performing a single sign-on for a mobile APP, you need to click the link in the browser to start the APP and upload the parameters to the corresponding interface in the APP for processing, now we will sort out the implementation process of calling Android and iOS applications through a browser and solidify it into a blog for query.

I. Use a browser to call Android applications

1) modify the configuration file AndroidManifest. xml and add the following configuration under the activity to be opened:





2) in HTML, add ssotest and click this link to open the APP.

3) Other apps can open the APP as follows:

StartActivity (new Intent (Intent. ACTION_VIEW, Uri. parse ("ssotest ://")));

4) if you want to pass the parameter, You can append it in the url, for example:

Ssotest

5) accept and parse parameters, and use the following code in the received Activity to obtain the parameters:

This. getIntent (). getScheme (); // get the Scheme name

This. getIntent (). getDataString (); // retrieve all Uri paths and parse the strings according to the format.

Ii. Use a browser to call the iOS app

1) modifyPlistFile to register external URLs

A: find info. plist of the project.

B: Click the plus sign next to the information property list and select URL types from the list.

C: Expand URL types, expand Item0, and change the URL identifier under Item0 to URL Scheme.

D: Expand the URL Scheme and change the content of Item0 to ssotest (which can be customized)

2) in HTML, add ssotest and click this link to open the APP.

3) If you want to accept the URL and perform special processing in the started APP, you can modify the project's AppDelegate. m and rewrite the openURL method as follows:

-(BOOL) application :( UIApplication *) application openURL :( NSURL *) url sourceApplication :( NSString *) sourceApplication annotation :( id) annotation

{

// You can use [url scheme] to obtain the defined Scheme name.

// You can use [url absoluteString] to obtain the entire URL path and parse the transmitted data.

}

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.