All Products
Search
Document Center

Mobile Platform as a Service:Check App

Last Updated:Feb 10, 2021

The interface is used to check App availability.

Use checkApp interface

  1. AlipayJSBridge.call('checkApp', {
  2. appId: '20000042',
  3. }, function(result) {
  4. console.log(result.status);
  5. if (result && result.status == 'installed') {
  6. // App is available
  7. }
  8. });

Code sample

Check App availability:

  1. <h1>Enter the App ID to check if the App exists</h1>
  2. <p>Note that the performance of `checkApp` API is inconsistent in Android and iOS. Therefore, it is not suggested to use it.</p>
  3. <input class="app" type="text" value="20000067">
  4. <a href="javascript:void(0)" class="btn check">Detection</a>
  5. <script>
  6. function ready(callback) {
  7. // Call directly if JSBridge has been injected
  8. if (window.AlipayJSBridge) {
  9. callback && callback();
  10. } else {
  11. // Monitor the injected events if JSBridge hasn't been injected
  12. document.addEventListener('AlipayJSBridgeReady', callback, false);
  13. }
  14. }
  15. ready(function() {
  16. document.querySelector('.check').addEventListener('click', function() {
  17. var appId = document.querySelector('.app').value;
  18. AlipayJSBridge.call('checkApp', {
  19. appId: appId
  20. }, function(e) {
  21. alert ('check result of' + appId + ':' + JSON.stringify(e))
  22. });
  23. });;
  24. });
  25. </script>

API

  1. AlipayJSBridge.call('checkApp',{
  2. appId, stageCode
  3. }, fn)

Input parameters

Name Type Description Required Default value Version
appId string App ID Y
stageCode string Stage code,”parentStageCode”: “marketStage”, “stageCode”: “homeStage”, “stageCode”: “recommend”, “stageCode”: “livingConvenience”, “stageCode”: “capitalTransactions”, “stageCode”: “shoppingEntertainment”, “stageCode”: “financialManagement”, “stageCode”: “educationWelfare”, “stageCode”: “othersStage” N
fn function Callback function N

Output parameters

Parameter results brought in by callback function: {exist, status, extStatus, version, type}.

Name Type Description Comment
exist bool Whether or not the app exists App existing does not indicate that it is available, as it may be offline
status string Value: installed, uninstalled Installed status indicates the App is available
extStatus string Online; uninstall; installing; offline Supported in the version 8.5 or higher. This field is only available for H5 Apps
version string Version of target App This field is only available for H5 Apps
type string Value is microApp This return field is only available for native Apps)

Attentions

  • The performance of checkApp API is inconsistent in Android and iOS. Therefore, it is not suggested to use it.