Permissions
Some interfaces require user authorization before they can be called. We divide these interfaces into multiple scopes according to the scope of use. Users choose to authorize the scope. After authorization is granted to a scope, all corresponding interfaces can be used directly.
When calling this type of interface:
- If the user has not accepted or rejected this permission, a pop-up window will be displayed to ask the user. The user can only call the interface after clicking "Agree";
- If the user has authorized, the interface can be called directly;
- If the user has rejected the authorization, no pop-up window will appear, but the interface fail callback will be directly entered. Developers are requested to be compatible with scenarios where users reject authorization.
Get user authorization settings
Developers can use wx.getSetting to get the user's current authorization status.
Open the settings interface
Users can control the authorization status of the mini program in the mini program settings interface ("upper right corner" - "Settings").
Developers can call wx.openSetting to open the settings interface and guide users to enable authorization.
Initiate authorization request in advance
Developers can use wx.authorize to initiate authorization requests to users in advance before calling the API that requires authorization.
scope list
| scope | Corresponding interface | Description |
|---|---|---|
| scope.userInfo | wx.getUserInfo | User information |
| scope.userLocation | wx.getLocation | Get geographic location information. |
| scope.userFuzzyLocation | wx.getFuzzyLocation | Get fuzzy geographic location information. |
| scope.writePhotosAlbum | wx.saveImageToPhotosAlbum | Whether to authorize saving to album wx.saveImageToPhotosAlbum |
Authorization validity period
Once the user explicitly agrees or refuses authorization, the authorization relationship will be recorded locally on the client until the mini program is deleted.
Usage suggestions
Initiate authorization request to users only when you really need to use the authorization interface, and explain the reason for using the function in the authorization request.