Detailed explanation of application arousal realization principle of IOS development

  • 2021-09-12 02:28:01
  • OfStack

1. What is iOS application evocation

The application call-up in IOS is used to realize the following functions: the local app of IOS mobile phone can be opened in some ways in the browser, and if the app is not installed, you can jump to the download page of App Store corresponding to the application.

2. App store download page connection

The connection form of the download page of an application in App store is as follows: https://itunes.apple.com/us/app/id399608199. Opening the connection in the PC browser will jump to the PC interface of the application details page. When the connection is opened in Safari, the browser will ask whether to open the connection in App Store. When you select Open, App Store will automatically open and jump to the download interface of the corresponding application.

3. URL Schemes

URL Schemes is very similar to URL. An URL can point to a website (for example, https://www.apple.com points to Apple official website) or a specific page within the website (for example, https://www.apple.com/mac/Mac points to Apple official website). An URL Schemes can also point to an APP (weixin://point to WeChat, an APP) or a function within APP (weixin://dl/moments/point to WeChat friends circle function).

Basic URL Schemes refers to this part as weixin://. With this basic URL Schemes, you can open an IOS APP application. For example, if you enter weixin://in the address bar of Safari, the browser will prompt whether to open WeChat. If you choose to open it, the mobile phone will automatically open the local WeChat application.

4. IOS application arousal method

1. Direct jump method (supports various versions of IOS system)

The simplest method is to use a tag to make a button in the page, and let its href point to the basic ES90Schemes that opens APP. Considering that it may not be installed locally, you need to have the browser jump to the corresponding App Store download page through the js code. You can set a reasonable reflection time. If the timeout has not opened the application, you can jump to the download page and use setTimeout method. The code is as follows:


$('a').click(function() { 
  location.href = 'weixin://'; 
  setTimeout(function() { 
    location.href = 'https://itunes.apple.com/us/app/id399608199'; 
  }, 500); 
} 

2. Use iframe (IOS 8 and later only supported)

This function can be realized by adding a hidden iframe to body and setting its internal src to the corresponding connection. The code is as follows:


var url = { 
 open: 'weixin://', // Corresponding Scheme 
 down: 'https://itunes.apple.com/us/app/id399608199'  // Corresponding download address  
}; 
var iframe = document.createElement('iframe'); // Create 1 A iframe 
var body = document.body; 
iframe.style.cssText='display:none;width=0;height=0'; // Set the iframe Is invisible  
var timer = null; 
var openapp = document.getElementById('openapp'); 
openapp.addEventListener('click', function() { 
 body.appendChild(iframe);  // Click Open app Button, put this iframe Add to body Medium  
 iframe.src = url.open; // Settings iframe Adj. src For weixin:// , through this iframe Make a jump  
 timer = setTimeout(function() { 
  wondow.location.href = url.down; //500ms Then jump to the download interface  
 }, 500); 
}, false) 

3. Use Universal links (currently only supported by IOS9)

Universal links is a new feature of IOS9, which is a normal HTTP connection. With Universal links, it is convenient to start APP (if app is installed on iOS device) or open the corresponding download interface (app is not installed on iOS device) through the traditional HTTP link.

Thank you for reading, hope to help everyone, thank you for your support to this site!


Related articles: