1e41f4b71Sopenharmony_ci# Access Token Changelog 2e41f4b71Sopenharmony_ci## cl.access_token.1 Behavior Change When Location Permission Is Requested by requestPermissionsFromUser 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci**Access Level** 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciPublic 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci**Reason for Change** 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ciAccording to privacy protection requirements, the location permission is added with the **Allow only while in use** option, and the **ohos.permission.LOCATION_IN_BACKGROUND** permission cannot be granted separately in a dialog box. 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciIf an application requires **ohos.permission.LOCATION_IN_BACKGROUND**, the permission must be granted by the user in **Settings**. For details, see **Adaptation Guide**. 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**Change Impact** 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciInvolved permissions: 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci- Foreground location permissions (used to control the behavior of a foreground application to obtain location information): 19e41f4b71Sopenharmony_ci - [ohos.permission.LOCATION](../../../application-dev/security/AccessToken/permissions-for-all.md#ohospermissionlocation): allows an application to obtain the precise location information of a device. This permission can be requested only after the ohos.permission.APPROXIMATELY_LOCATION permission is available. 20e41f4b71Sopenharmony_ci - [ohos.permission.APPROXIMATELY_LOCATION](../../../application-dev/security/AccessToken/permissions-for-all.md#ohospermissionapproximately_location): allows an application to obtain approximate location information of a device. 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci- Background location permission (used to control the behavior of a background application to obtain location information): 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci [ohos.permission.LOCATION_IN_BACKGROUND](../../../application-dev/security/AccessToken/permissions-for-all.md#ohospermissionlocation_in_background): allows an application running in the background to obtain device location information. This permission can be requested only after the foreground location permissions are available. 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ciThe following scenarios are involved: 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_cia) The application requests only the background location permission (without the foreground location permissions). 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ciBefore the change:<br>A dialog box will be displayed for granting the **ohos.permission.LOCATION_IN_BACKGROUND** permission. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ciAfter the change:<br>The **ohos.permission.LOCATION_IN_BACKGROUND** permission cannot be granted by the user in a dialog box. 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_cib) The application requests only the background location permission (with the foreground location permissions available). 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ciBefore the change:<br>The **ohos.permission.LOCATION_IN_BACKGROUND** permission is granted when the **ohos.permission.LOCATION** permission is granted for the first time. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ciAfter the change:<br>The **ohos.permission.LOCATION_IN_BACKGROUND** permission cannot be granted by the user in a dialog box. 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_cic) The application requests both the foreground and background location permissions. 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ciBefore the change:<br>A dialog box containing **Allow** and **Deny** will be displayed for granting the permissions. 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ciAfter the change: 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ciAPI 10 and earlier: A dialog box containing **Allow only while in use** and **Deny** will be displayed. If **Allow only while in use** is selected, only the **ohos.permission.LOCATION** permission is granted. 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ciAPI 11 and later: No dialog box will be displayed for granting the foreground and background location permissions. 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci**API level** 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci9 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**Change Since** 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ciOpenHarmony SDK 4.1.5.3 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci**Key API/Component Changes** 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci[requestPermissionsFromUser](../../../application-dev/reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) in @ohos.abilityAccessCtrl.d.ts 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci**Affected APIs** 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci| File| API| 65e41f4b71Sopenharmony_ci| -------- | -------- | 66e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.on('locationChange') | 67e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.off('locationChange') | 68e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.on('locationServiceState') | 69e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.off('locationServiceState') | 70e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.on('cachedGnssLocationsReporting') | 71e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.off('cachedGnssLocationsReporting') | 72e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.on('gnssStatusChange') | 73e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.off('gnssStatusChange') | 74e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.on('nmeaMessageChange') | 75e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.off('nmeaMessageChange') | 76e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.on('fenceStatusChange') | 77e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.off('fenceStatusChange') | 78e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.getCurrentLocation | 79e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.getLastLocation | 80e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.isLocationEnabled | 81e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.requestEnableLocation | 82e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.isGeoServiceAvailable | 83e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.getAddressesFromLocation | 84e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.getAddressesFromLocationName | 85e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.getCachedGnssLocationsSize | 86e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.flushCachedGnssLocations | 87e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | geolocation.sendCommand | 88e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | SatelliteStatusInfo | 89e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | CachedGnssLocationsRequest | 90e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | GeofenceRequest | 91e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | Geofence | 92e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | ReverseGeoCodeRequest | 93e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | GeoCodeRequest | 94e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | GeoAddress | 95e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | LocationRequest | 96e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | CurrentLocationRequest | 97e41f4b71Sopenharmony_ci| @ohos.geolocation.d.ts | Location | 98e41f4b71Sopenharmony_ci| @ohos.geoLocationManager.d.ts | geoLocationManager.on('nmeaMessage') | 99e41f4b71Sopenharmony_ci| @ohos.geoLocationManager.d.ts | geoLocationManager.off('nmeaMessage') | 100e41f4b71Sopenharmony_ci| @ohos.geoLocationManager.d.ts | geoLocationManager.on('locatingRequiredDataChange') | 101e41f4b71Sopenharmony_ci| @ohos.geoLocationManager.d.ts | geoLocationManager.off('locatingRequiredDataChange') | 102e41f4b71Sopenharmony_ci| @ohos.geoLocationManager.d.ts | geoLocationManager.getLocatingRequiredData | 103e41f4b71Sopenharmony_ci| @ohos.bluetooth.d.ts | bluetooth.startBluetoothDiscovery | 104e41f4b71Sopenharmony_ci| @ohos.bluetooth.d.ts | startBLEScan | 105e41f4b71Sopenharmony_ci| @ohos.bluetoothManager.d.ts | bluetoothManager.startBluetoothDiscovery | 106e41f4b71Sopenharmony_ci| @ohos.bluetoothManager.d.ts | startBLEScan | 107e41f4b71Sopenharmony_ci| @ohos.telephony.observer.d.ts | observer.on('cellInfoChange') | 108e41f4b71Sopenharmony_ci| @ohos.telephony.radio.d.ts | radio.sendUpdateCellLocationRequest | 109e41f4b71Sopenharmony_ci| @ohos.telephony.radio.d.ts | radio.getCellInformation | 110e41f4b71Sopenharmony_ci| @system.geolocation.d.ts | GetLocationOption | 111e41f4b71Sopenharmony_ci| @system.geolocation.d.ts | SubscribeLocationOption | 112e41f4b71Sopenharmony_ci| @system.geolocation.d.ts | geolocation.getLocation | 113e41f4b71Sopenharmony_ci| @system.geolocation.d.ts | geolocation.subscribe | 114e41f4b71Sopenharmony_ci| @system.geolocation.d.ts | geolocation.unsubscribe | 115e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.scan | 116e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.getScanInfos | 117e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.getDeviceConfigs | 118e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.getStations | 119e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.getCurrentGroup | 120e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.getP2pPeerDevices | 121e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.p2pConnect | 122e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.startDiscoverDevices | 123e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.on('p2pDeviceChange') | 124e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.off('p2pDeviceChange') | 125e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.on('p2pPeerDeviceChange') | 126e41f4b71Sopenharmony_ci| @ohos.wifi.d.ts | wifi.off('p2pPeerDeviceChange') | 127e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.scan | 128e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getScanResults | 129e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getScanResultsSync | 130e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getCandidateConfigs | 131e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getDeviceConfigs | 132e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getStations | 133e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getCurrentGroup | 134e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getP2pPeerDevices | 135e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.p2pConnect | 136e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.startDiscoverDevices | 137e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.getP2pGroups | 138e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.on('p2pDeviceChange') | 139e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.off('p2pDeviceChange') | 140e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.on('p2pPeerDeviceChange') | 141e41f4b71Sopenharmony_ci| @ohos.wifiManager.d.ts | wifiManager.off('p2pPeerDeviceChange') | 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci**Adaptation Guide** 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci1. Request the foreground and background location permissions for your application using **requestPermissionsFromUser**. 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci a) Check whether the application requires the background location permission. If yes, request the foreground location permissions first. 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci Change: 150e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION', 'ohos.permission.LOCATION_IN_BACKGROUND'], ......) 151e41f4b71Sopenharmony_ci To: 152e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION'], ......) 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci Or change: 155e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION_IN_BACKGROUND'], ......) 156e41f4b71Sopenharmony_ci To: 157e41f4b71Sopenharmony_ci <br>atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION'], ......). 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci b) After the user has granted the foreground location permissions, a dialog box is displayed, informing the user to grant the background location permission in **Settings**. 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci c) The user selects **Always allow** on the **Settings** screen to grant the background location permission. 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci2. Request only the background location permission for your application using **requestPermissionsFromUser**. 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ci a) Check whether the application requires the background location permission. If yes, request the foreground location permissions in a dialog box first. 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_ci Change: 168e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ['ohos.permission.LOCATION_IN_BACKGROUND'], ......) 169e41f4b71Sopenharmony_ci To: 170e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION'], ......) 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci Or change: 173e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ['ohos.permission.LOCATION_IN_BACKGROUND'], ......) 174e41f4b71Sopenharmony_ci To: 175e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION'], ......). 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci b) See the steps in case 1. 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ciFor details about the sample code, see [**requestPermissionsFromUser**](../../../application-dev/reference/apis-ability-kit/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9). 180