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