The interface is used to check App availability.
Use checkApp interface
AlipayJSBridge.call('checkApp', {
appId: '20000042',
}, function(result) {
console.log(result.status);
if (result && result.status == 'installed') {
// App is available
}
});
Code sample
Check App availability:
<h1>Enter the App ID to check if the App exists</h1>
<p>Note that the performance of `checkApp` API is inconsistent in Android and iOS. Therefore, it is not suggested to use it.</p>
<input class="app" type="text" value="20000067">
<a href="javascript:void(0)" class="btn check">Detection</a>
<script>
function ready(callback) {
// Call directly if JSBridge has been injected
if (window.AlipayJSBridge) {
callback && callback();
} else {
// Monitor the injected events if JSBridge hasn't been injected
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function() {
document.querySelector('.check').addEventListener('click', function() {
var appId = document.querySelector('.app').value;
AlipayJSBridge.call('checkApp', {
appId: appId
}, function(e) {
alert ('check result of' + appId + ':' + JSON.stringify(e))
});
});;
});
</script>
API
AlipayJSBridge.call('checkApp',{
appId, stageCode
}, 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.