1# (Optional) Using canOpenLink to Check Application Accessibility 2<!--Kit: Ability Kit--> 3<!--Subsystem: BundleManager--> 4<!--Owner: @wanghang904--> 5<!--Designer: @hanfeng6--> 6<!--Tester: @kongjing2--> 7<!--Adviser: @Brilliantry_Rui--> 8 9## When to Use 10Before starting application B, application A can call **canOpenLink** to check whether application B is accessible. 11 12> **NOTE** 13> 14> The **canOpenLink** API cannot be used to determine whether the application navigated to via App Linking is installed. 15 16## Constraints 17A maximum of 50 URL schemes can be configured in the [querySchemes](../quick-start/module-configuration-file.md) field in the **module.json5** file of the entry module. 18## Available APIs 19**canOpenLink** is provided by the [bundleManager](../reference/apis-ability-kit/js-apis-bundleManager.md#bundlemanagercanopenlink12) module to check whether a target application is accessible. 20 21For details about the matching rules, see [Matching Rules of Explicit Want and Implicit Want](explicit-implicit-want-mappings.md). 22 23## How to Develop 24### Procedure for the Caller Application 25 261. Configure the [querySchemes](../quick-start/module-configuration-file.md) field in the **module.json5** file of the entry module to declare the URL schemes. 27 28 ```json 29 { 30 "module": { 31 //... 32 "querySchemes": [ 33 "app1Scheme" 34 ] 35 } 36 } 37 ``` 38 392. Import the **ohos.bundle.bundleManager** module. 403. Call **canOpenLink**. 41 42 ```ts 43 import { bundleManager } from '@kit.AbilityKit'; 44 import { BusinessError } from '@kit.BasicServicesKit'; 45 import { hilog } from '@kit.PerformanceAnalysisKit'; 46 try { 47 let link = 'app1Scheme://test.example.com/home'; 48 let canOpen = bundleManager.canOpenLink(link); 49 hilog.info(0x0000, 'testTag', 'canOpenLink successfully: %{public}s', JSON.stringify(canOpen)); 50 } catch (err) { 51 let message = (err as BusinessError).message; 52 hilog.error(0x0000, 'testTag', 'canOpenLink failed: %{public}s', message); 53 } 54 ``` 55 56### Procedure for the Target Application 57Configure the [uris](../quick-start/module-configuration-file.md#skills) field in the **module.json5** file. 58 59```json 60{ 61 "module": { 62 //... 63 "abilities": [ 64 { 65 //... 66 "skills": [ 67 { 68 // actions cannot be empty. Otherwise, matching the target application fails. 69 "actions": ["ohos.want.action.home"], 70 "uris": [ 71 { 72 "scheme": "app1Scheme", 73 "host": "test.example.com", 74 "pathStartWith": "home" 75 } 76 ] 77 } 78 ] 79 } 80 ] 81 } 82} 83``` 84 85## FAQ 861. Why is there a limit of 50 URL schemes in querySchemes? 87 88 The **canOpenLink()** API is used to check whether an application is accessible. It indirectly reveals whether a specific application is installed. 89 90 To protect system security and user privacy and to prevent malicious applications from scanning the list of installed applications, you must configure the **querySchemes** property when using the **canOpenLink()** API. The maximum number of URL schemes that can be configured is 50 URL schemes. 91