Слияние кода завершено, страница обновится автоматически
private permissions: Array<Permissions> = [
// "ohos.permission.USE_BLUETOOTH",
// "ohos.permission.DISCOVER_BLUETOTH",
// "ohos.permission.CAMERA",
"ohos.permission.ACCESS_BLUETOOTH",
"ohos.permission.APPROXIMATELY_LOCATION",
"ohos.permission.LOCATION",
];
TaoYao.with(this.context)
.runtime()
.permission(this.permissions)
.onGranted(permissions => {
// Successful acquisition of access permissions
// this.startScan();
console.log("Access permissions acquired", permissions);
this.toast("Access permissions acquired");
})
.onDenied(permissions => {
/*
* 1. Due to security and confidentiality requirements, the application cannot obtain permission for background location data through system dialog windows. The application must first request approximate location and precise location, then show the user a dialog window so they can open the corresponding settings in the system. If the user selects "always allow" access to location, the application will acquire permission for background location data.
* 2. If the request for access permissions ends with the user's refusal, the system will no longer offer dialog windows to obtain these permissions. In this case, the application should display a dialog window to the user so they can open the corresponding settings in the system.
*/
this.showPermissionDialog(permissions);
})
// Start requesting access permissions
.request();
```// Если уже были получены права доступа к местоположению, то запрос на получение других прав доступа, таких как камера и Bluetooth, не выполняется;
// Я заметил, что если массив прав доступа содержит права доступа к местоположению, то будут запрошены только эти права. Если же нет прав доступа к местоположению, например, если запрашиваются права доступа к камере и Bluetooth, всё работает корректно.