Client API
User Manager
Use appGallery.getUserManager()
to get the globally unique user manager instance.
getAuthCode
Description
After the user logs into the host app (Lovense Remote App), call this interface to obtain user information authorization and obtain an authorization code (authCode).
Parameters
Attribute Type Default Required Introduction scope String Yes Authentication Type,
authBase
: Silent authorization, no authorization pop-up will appear;
authUser
: User authorization, an authorization pop-up will appearsuccess function No Callback function for successful API call fail function No Callback function for failed API call Success callback function will receive an object with the following attributes:
Attribute Type Introduction authCode string Authorization code Fail callback function will receive an object with the following attributes:
Attribute Type Introduction code string Error code msg string Error message Example
// Get user manager instance const userManager = appGallery.getUserManager(); // User authorization userManager.getAuthCode({ scope: "authUser", // Authorization type success(res) { console.log(res.authCode) // Print the obtained authorization code }, fail(err) { console.error(err.code) // Print error code console.error(err.msg) // Print error message }, });
authorize
Description
Initiate authorization requests to users in advance. Immediately after the call, a pop-up asks if the user agrees to authorize the mini-app to use a function or get some data from the user, but does not actually call the corresponding interface. If the user has previously agreed to the authorization, there will be no pop-up window, directly return success.
Parameters
Attribute Type Default Required Introduction scope String Yes Need to get permission scope: scope.writePhotosAlbum
: save the image to system albumsuccess function No Callback function for successful API call fail function No Callback function for failed API call Success callback function will receive an object with the following attributes:
Attribute Type Introduction code string Success code Fail callback function will receive an object with the following attributes:
Attribute Type Introduction code string Error code msg string Error message Example
// Get user manager instance const userManager = appGallery.getUserManager(); userManager.authorize({ scope: 'scope.writePhotosAlbum', success(res) { console.log(res.code) }, fail(err) { console.error(err.code) console.error(err.msg) } });
getAuthSetting
Description
User's current authorize settings results.
Parameters
Attribute Type Default Required Introduction success function No Callback function for successful API call fail function No Callback function for failed API call Success callback function will receive an object with the following attributes:
Attribute Type Introduction authSetting AuthSetting User's Current Authorize Settings Results Fail callback function will receive an object with the following attributes:
Attribute Type Introduction code string Error code msg string Error message Example
// Get user manager instance const userManager = appGallery.getUserManager(); userManager.getAuthSetting({ success(res) { console.log(res.authSetting) // res.authSetting = { // "scope.writePhotosAlbum": true // } }, fail(err) { console.error(err.code) console.error(err.msg) }, });
AuthSetting
When using getAuthSetting
to get user's current authorize settings results, will get authSetting data.
For each item in a authSetting are as follows:
Attribute | Type | Introduction |
---|---|---|
scope.writePhotosAlbum | boolean | Authorize Save to Album |