Call Android or iOS app via browser

Source: Internet
Author: User

When doing a mobile app single Sign-on, you need to click on the link in the browser to launch the app and upload the parameters to the corresponding interface in the app to process, will now be called through the browser Android and iOS app implementation process to be cured to the blog for query.

One: Call Android app via browser

1) Modify the configuration file Androidmanifest.xml and add the following configuration under activity that needs to be opened:

<intent-filter>

<data android:scheme= "Ssotest"/><!--Open the application through this ssotest, which you can define yourself. -
<action android:name= "Android.intent.action.VIEW"/>
<category android:name= "Android.intent.category.DEFAULT"/>
<category android:name= "Android.intent.category.BROWSABLE"/>
</intent-filter>

2) in HTML, add <a href= ' ssotest://' >ssotest</a> Click this link to open the app.

3) Other apps can also open the app as follows:

startactivity (new Intent (Intent.action_view, Uri.parse ("ssotest://"));

4) If you want to pass a parameter, you can append it to the URL, for example:

<a href= ' ssotest://id=123456 ' >ssotest</a>

5) Accept and parse the parameters and use the following code to obtain the parameters in the received activity:

This . Getintent (). Getscheme (); //Get scheme name   

This . Getintent (). getdatastring (); //Get the full URI path and parse the string yourself according to the format.

Second: Call iOS app via browser

1) Modify the plist file, register the external URL

A: find the <app>info.plist of the project

B: Click the plus sign behind the Information property list to select the URL from the list types

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

D: Expand URL Scheme To modify the contents of Item0 to Ssotest (customizable)

2) in HTML, add <a href= ' ssotest://' >ssotest</a> Click this link to open the app.

3) If you want to accept this URL in the launch app and do special processing, you can modify the APPDELEGATE.M of the projectand rewrite the OpenURL method as follows:

-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (id) annotation

{

a defined scheme name can be obtained through [URL scheme]

The entire URL path can be obtained through [url absolutestring] to parse the data passed in.

}

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.