May 18, 2021 WeChat Mini Program Development Document
Some interfaces require user authorization consent before they can be invoked. We divide these interfaces into scopes by scope of use, and the user chooses to authorize scope, and when granted to a scope, all of its corresponding interfaces can be used directly.
When such interfaces are called:
Developers can use wx.getSetting to obtain the user's current authorization status.
The user can control the authorization status of the small program in the small program settings interface ("top right corner" - "About" - "top right corner" - "Settings").
Developers can call wx.openSetting to open the settings interface and direct the user to open the authorization.
Developers can use wx.authorize to initiate authorization requests to users in advance before calling the authorization API.
scope | The corresponding interface | Describe |
---|---|---|
scope.userInfo | wx.getUserInfo | User information |
scope.userLocation | wx.getLocation, wx.chooseLocation | Location |
scope.userLocationBackground | wx.startLocationUpdateBackground | Background positioning |
scope.address | wx.chooseAddress | mailing address |
scope.invoiceTitle | wx.chooseInvoiceTitle | Invoice |
scope.invoice | wx.chooseInvoice | Get invoices |
scope.werun | wx.getWeRunData | WeChat sports step |
scope.record | wx.startRecord | recording function |
scope.writePhotosAlbum | wx.saveImageToPhotosAlbum, wx.saveVideoToPhotosAlbum | save into the album |
scope.camera | Camera components | Camera |
Once a user explicitly consents or rejects authorization, its authorization relationship is recorded in the background until the user actively deletes the small program.
When you really need to use the authorization interface, you initiate an authorization request to the user and state the reasons for using the feature clearly in the authorization request.
Unlike other types of authorizations, scope.userLocationBackground does not play a window to alert the user. T he user is required to proactively set the Location Information option to "During and after using a small program" on the settings page. Developers can open the settings page by calling wx.openSetting.