Got Stuck?
Forum for Lovense Developers
Support
Document Feedback

Introduction

The App Gallery provides a mini-app platform within the App Gallery feature of the Lovense Remote App to host full Web Apps. This will allow for flexible interfaces that can seamlessly integrate with Lovense toys.

Developers can easily and efficiently utilize these APIs to accomplish relevant tasks.

Create and Release Your Apps

Preparation

Register Lovense Developer accountopen in new window to access the developer dashboard.

Visit the developer dashboardopen in new window and click on App Gallery solutions, then click the “Go to Console” button.

dashboard

Step 2: Create a New App and fill in the Basic Information

Click the “New App” button on the Apps page to create a new App.

App Gallery Console

Click on “Basic Information” in the sidebar an complete the form.

Basic Information

Example of Basic Information is displayed in App Gallery.

App Gallery

Example of User Privacy Protection Guidelines.

User Privacy Protection

Note: If you do not need to collect user information, please select the 1st option. Otherwise, select the 2nd option.

Step 3: Develop Your App

Refer to the APIs document to find out what functionality Lovense Remote app provides.

Prerequisites

Before calling the API, it's necessary to listen for the deviceready event to ensure that appGallery is ready. It guarantees that the API will function properly.

  • Example
document.addEventListener('deviceready', onAppGalleryReady, false)

function onAppGalleryReady() {
// appGallery is now initialized
}

Step 4: Debug Your App

Configuration File

Before debugging the app, you need to create a file, called appgallery_config.json. The appgallery_config.json file should be placed in the root directory of the Web App, which is used for global configuration of the app.

Create Config Json File

The file content is a JSON object with the following properties:

AttributeTypeDefaultRequiredIntroduction
versionStringYesThis version of the App Gallery SDK used by the mini-app, "2" will indicate that the 2.x version is being used.
- This is currently version 2 and is supported by Lovense Remote App version 7.14.0 and above.
- The mini-app functionality requires support from Lovense Remote App. Each new feature added to the App Gallery SDK requires a specific version of the Lovense Remote App. Some new features in a later version of the SDK may not be compatible with earlier versions of Remote app.
appIdStringYesThe appId is the App ID you create on App Gallery Console.
appVersionStringYesThe appVersion is the version number you create on App Gallery Console.
permissionArrayNoThe permissions required by the Web App. Available permissions are:  
 - user_info: User information
 - toy_info: Toy information
allowDomainsArrayNoThe allowed list of server domains is a restrictive measure implemented to ensure application security. In the case of API calls made by the web app, communication is limited to the domain names listed. For instance, only HTTP requests to the authorized domain names are allowed.

Get the appId and appVersion from App Gallery Console.

App Id And App Version

Example (appgallery_config.json):

{
  "version": "2",
  "appId": "is6cbb054xxxxea42xxx17f7xxx1abxxxxx",
  "appVersion": "1.0",
  "permission": ["user_info", "toy_info"],
  "allowDomains": ["*.example.com"]
}

Generate Debug QR Code

You can deploy the web app you're developing locally or to a server. Then generate the QR code, the link should be: https://server:port/index.html

Developer Mode

There is a switch of Developer Mode on Lovense Remote app for running web apps under development. Go to Settings page then tap “Settings” at the top three times to make the switch visible.

Developer Mode

With Developer Mode enabled, Lovense Remote app can run the web app via scanning the QR code.

Run your App using Lovense Remote app

After scanning the QR Code, Lovense Remote app will directly open your App page.

Debug Vconsole More Settings

  1. When you want to see the logs and additional debugging information output by the console, click on the button vConsole .

  2. Click on the button ... (represented by three dots) in the top-right corner.

  3. Clicking settings will open the settings pop-up box, displaying two options: Auto-Clear Cache and Enable allowDomains. By default, Auto-Clear Cache is enabled and Enable allowDomains is disabled.

  4. If the app needs to access other links or resources via the network, you need to format all the access link domains, and configure into the allowDomains properties in the appgallery_config.json file, and enable the switch for the allowDomains. Then select Reopen or rescan the QR code to check.

Step 5: Package Your Code

After completing the development, it is necessary to select all the files and package your code as a zip file. Please ensure that you do not directly select the outer folder for compression. Please follow these requirements.

  1. All files must be placed in the root directory.
  2. The zip file must contain the index.html file.
  3. The zip file must contain the configuration file: appgallery_config.json.
  4. The size of the zip file should be less than 100 MB.

App Files

Step 6: Submit for Review

After debugging your program, submit the code for review in the App Gallery Console.

Submit for Review

If the version that has been submitted for review is rejected or revoked, click the “+” icon to create a new version for submission.

New Version

Once the App is approved, your app will be displayed in App Gallery.

User Authorization

Access to user information requires user authorization. When calling userManager.getAuthCode, a pop-up window will appear to ask the user if he/she wants to accept.

user authorization

Authorization Process

Get authCode

The developer can use userManager.getAuthCode to get authCode.

When calling it

  • scope is a core parameter that affects accessToken's ability to access resources.
  • authCode is valid for a single use and will expire after that. Repeated use of authCode triggers alerts.
  • authCode will expire in 3 minutes, so please get the accessToken and userId using authCode as soon as possible.

Use appSecret to encrypt authCode into sign

How to encrypt:

  • The developer uses App Secret as the key to encrypt the authCode to produce a sign. Go to App Gallery Console to get the App Secret.
  • The encryption method, signType, can only use HmacSHA256 at this time.
  • The encrypted string should be Base64 encoded.

Lovense Remote server will compare the decrypted sign to authCode, and access will be denied if the comparison fails.

Java Code Example

import sun.misc.BASE64Encoder;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;

public String useSecretGenerateSign(String authCode, String appSecret) throws Exception {
    Mac sha256HMAC = Mac.getInstance("HmacSHA256");
    SecretKeySpec secretKey = new SecretKeySpec(appSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
    sha256HMAC.init(secretKey);
    byte[] bytes = sha256HMAC.doFinal(authCode.getBytes(StandardCharsets.UTF_8));
    return (new BASE64Encoder()).encodeBuffer(bytes);
}

Get Access Token and User ID using authCode

The developer can use Get Access Token HTTP API and Get User Info HTTP API to get accessToken and userId.

Calling the interface with authCode to get an accessToken also returns a refreshToken, which can be used to refresh a new accessToken within the refreshToken's validity period.

The accessToken is used to access the lovense APIs, which determine the scope of the accessToken's privileges and only allow access to interfaces within that scope.

Java Code Example

URI uri  = new URIBuilder().setScheme("https").setHost("appgallery.lovense.com").setPath("/remote-dev-api/oauth").build();

HttpPost post = new HttpPost(uri);
post.setHeader("Content-Type", "application/json;charset=utf8");
post.setHeader("developerToken", developerToken);

// user HttpClient
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
CloseableHttpResponse response = httpClient.execute(post);
// gets the response entity from the response model
HttpEntity responseEntity = response.getEntity();

// assemble request body
String appId = "your appId";
String appSecret = "your appSecret";
String grantType = "authorizationCode"; // or refreshToken

Param param = new Param();
param.setAppId(appId);
param.setGrantType(grantType);
if (Objects.equals("refreshToken", param.getGrantType())) {
    String refreshToken = "Persist refreshToken in your server";
    param.setFreshToken(refreshToken);
} else if (Objects.equals("authorizationCode", param.getGrantType())) {
    String authCode = "authCode obtained from the sdk";
    String sign = this.useSecretGenerateSign(param.getAuthCode(), appSecret);
    param.setAuthCode(authCode);
    param.setSign(sign);
    param.setSignType("HmacSHA256"); // Currently, only HmacSHA256 is accepted

}
StringEntity entity = new StringEntity(JsonUtil.toJson(param), "UTF-8");
post.setEntity(entity);

// send request
String contentStr = EntityUtils.toString(responseEntity);

DataResponse content = JsonUtil.toBean(contentStr, DataResponse.class);
OAuthResponseData data = JsonUtil.toBean(JsonUtil.toJson(content.getData()), OAuthResponseData.class);

class AccessUserInfo {

    private boolean result;

    private int code;

    private Strig message;

    private Object data;

  // omit getter and setter methods
}

class OAuthResponseData {

    private String accessToken;

    private Long expiresIn;

    private String refreshToken;

    private Long reExpiresIn;

    private String userId;

  // omit getter and setter methods
}

Get userInfo using accessToken

The developer can use this interface to get userInfo:

GetUserInfo Request

Java Code Example

// obtain user information using accessToken
URI uri  = new URIBuilder().setScheme("https").setHost("appgallery.lovense.com").setPath("/remote-dev-api/user/info").build();

HttpPost post = new HttpPost(uri);
post.setHeader("Content-Type", "application/json;charset=utf8");
post.setHeader("developerToken", developerToken); // your developerToken
post.setHeader("accessToken", accessToken); // accessToken from step2

// user HttpClient
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
CloseableHttpResponse response = httpClient.execute(post);
// gets the response entity from the response model
HttpEntity responseEntity = response.getEntity();
String contentStr = EntityUtils.toString(responseEntity);

DataResponse content = JsonUtil.toBean(contentStr, DataResponse.class);
AccessUserInfo data = JsonUtil.toBean(JsonUtil.toJson(content.getData()), AccessUserInfo.class);

class AccessUserInfo {

    private boolean result;

    private int code;

    private Strig message;

    private Object data;

  // omit getter and setter methods
}

class AccessUserInfo {

    private String name;

  // omit getter and setter methods
}

Server API

Get Access Token HTTP API

API URL: https://appgallery.lovense.com/remote-dev-api/oauth

Method: POST

Content Type:  application/json

Headers:

NameDescriptionTypeRequired
developerTokenDeveloper tokenstringyes

Parameters:

NameDescriptionTypeNoteRequired
appIdAppcation IDstringGet Appcation ID from App Gallery Consoleyes
grantTypeDecide whether to get authCode or refreshTokenstringauthorizationCode: used when exchanging authCode for accessToken. refreshToken: used when exchanging refreshToken for accessTokenyes
authCodeThe authCode obtained in the first stepstringRequired if grantType=authorizationCodeno
signSign of authCode. It is used to verify that the authcode is legal.stringRequired if grantType=authorizationCode and use appSecret as encryption keyno
signTypeEncryption methodstringRequired if grantType=authorizationCode and HmacSHA256 only for now.no
refreshTokenThe refreshToken obtained previouslystringRequired if grantType=refreshTokenno

Response:

NameDescriptionType
resultInterface request resultboolean
codeInterface response valueint
messageThe interface returns a message, "success" on success.string
accessToken-string
expiresInThe timestamp of accessTokennumber
refreshToken-string
reExpiresInThe timestamp of refreshTokennumber
userIdThe user id of the accountstring

Note:

  • The users can cancel the authorization, once canceled, the accessToken and refreshToken will be invalidated immediately.
  • When you call the interface with refreshToken, you get a new accessToken, the accessToken expiration date is refreshed and the original accessToken expires immediately. At the same time, you will get a new refreshToken, the original refreshToken will be invalid, and the validity period of the new refreshToken will not be refreshed.

Request Example:

{
  "appId": "8b037229f05d4846a780f94c01217c86",
  "grantType": "authorizationCode",
  "authCode": "8f8039620d97682f5dc2233c0846f4c9801cd5e98e10b495cf874b01e40dff25",
  "sign": "BBEEgnnb7Ff6FXTI9nnYEFHh79dZa3WW7H61I25ZALuunPuc/VPs2usZuo1cXxZE",
  "signType": "HmacSHA256",
  "refreshToken": ""
}

Response Example:

{
  "result": true,
  "code": 0,
  "message": null,
  "data": {
    "accessToken": "C6cB322UtP14uR6DLgPRtbyBXL+wjb6NFuM1tCXMwly+6RhaCOh27euJvteoBxltRT0RYsGlEGT5aZv/WF8ZPiaNhC+L+cSoR1cnXpxFaThqkuPIWCyAFjQDR433qaeyxISeLGGFjLTxvWlwBAhRqSxTo8ahswpfRUbOHRBVxnGtDp8Ks81bEEYc4zIa0/oFxyo6+eEDPfAU/Drm0Mw/EhFfwc8lLoptF7uo20iNEQ4P73V4INLWkXbSKKOrhTwQyabEGAoOiZ2LMXEN2JxK16zL9GcVNAkaQBwEWYpNaDvX9U/tQp+A+ct/ztpPUxKWaNck1B/+FESh4aK7Jh+RK52K4sQfJL3APiU5pYl3YI4=",
    "expiresIn": 1698390847916,
    "reExpiresIn": 31536000,
    "refreshToken": "chBKBBkUmZ2NHIcTOVKH6AX2wbkeEwA0bbJVd0LZL8+eFmWsTt9NDt78YcOwFGvsPXNABQ/Jicu7vmh8maBsaZBSgV17PyY+JcHv7x8tPYUK2yTO3Nes/mFwvkqEQaTJQ8ofqRYlnY034UojqGW2/cwaK/X3fYtdIZE1GS/X6i7WX04JpASZgaFaS5yuyp2q8Ioze4fTSt+uvtTGKv/aKhfVwhz4cdXfKGWlOt1vTEc4+1OqHjRuTDFfzBT3aD9YIldP142OPYHnBAZzXfnMK3JFNe9vvU7g/XrJR9AqJ86XfZoDkDJCGX0Y+RkxxL7oPbirOpj6PhaeyFiZkayMXQ==",
    "userId": "IfoQ0JsqJ9rUKS7YzhpsHHD33TmqcDufPV6dKTnsvx3qGZ/gYkb5ZgNCKaP5cz04"
  }
}

Get User Info HTTP API

API URL: https://appgallery.lovense.com/remote-dev-api/user/info

Method: POST

Content Type: application/json

Headers:

NameDescriptionTypeRequired
developerTokenDeveloper tokenstringyes
accessTokenThe accessToken obtained in the second stepstringyes

Response:

NameDescriptionType
resultInterface request resultboolean
codeInterface response valueint
messageThe interface returns a message, "success" on success.string
nameThe username that the user agrees to authorizestring

Request Example:

curl -X POST https://appgallery.lovense.com/remote-dev-api/user/info \
-H "Content-Type: application/json" \
-H "developerToken: xxxxxx" \
-H "accessToken: xxxxxxxxxx"

Response Example:

{
  "result": true,
  "code": 0,
  "message": null,
  "data": {
    "name": "lovenseDevTest"
  }
}

API

User Manager

Use appGallery.getUserManager() to get the globally unique toy 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

    AttributeTypeDefaultRequiredIntroduction
    scopeStringYesAuthentication Type,
    authBase: Silent authorization, no authorization pop-up will appear;
    authUser: User authorization, an authorization pop-up will appear
    successfunctionNoCallback function for successful API call
    failfunctionNoCallback function for failed API call

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    authCodestringAuthorization code

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError 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

    AttributeTypeDefaultRequiredIntroduction
    scopeStringYesNeed to get permission scope: scope.writePhotosAlbum: save the image to system album
    successfunctionNoCallback function for successful API call
    failfunctionNoCallback function for failed API call

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringSuccess code

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError 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

    AttributeTypeDefaultRequiredIntroduction
    successfunctionNoCallback function for successful API call
    failfunctionNoCallback function for failed API call

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    authSettingAuthSettingUser's Current Authorize Settings Results

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError 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:

AttributeTypeIntroduction
scope.writePhotosAlbumbooleanAuthorize Save to Album

Toy

Toy Manager

Use appGallery.getToyManager() to get the globally unique toy manager instance.

getMyToysInfo
  • Description

    Get the information of toy list.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    successfunctionNoCallback function for successful API call
    failfunctionNoCallback function for failed API call

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    toyListArrayToy List

    Success callback function received parameters data example:

    {
    "toyList": [{
      "showName": "Lapis",
      "alias": "001",
      "firmwareVersion": "",
      "type": "z10",
      "toyId": "6c5cb14619b1",
      "battery": "98",
      "status": "0",
      "isSupportFeedbackMode": true
    }, {
      "showName": "Ridge",
      "alias": "",
      "firmwareVersion": "",
      "type": "ridge",
      "toyId": "e0798d436ab4",
      "battery": "98",
      "status": "1",
      "isSupportFeedbackMode": true
    }]
    }
    

    Fail callback function will receive an object with the following attributes:

AttributeTypeIntroduction
codestringError code
msgstringError message
  • Example

    const toyManager = appGallery.getToyManager()
    
    // Get the toy information
    toyManager.getMyToysInfo({
      success(res) {
        console.log(res.toyList)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
onMyToysChange
  • Description

Set up a listener to receive updates on the connection status or quantity of toys. This will allow you to retrieve the latest information about your toys.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    callbackfunctionYesListener function for toy connection status or quantity changes.

    The callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    toyListArrayToy List
  • Example

    const toyManager = appGallery.getToyManager()
    
    // Listen to changes in my toys
    toyManager.onMyToysChange(function (res) {
      console.log(res.toyList)
    })
    
openMyToysDialog
  • Description

    Open the pop-up window of my toy page.

  • Example

    const toyManager = appGallery.getToyManager()
    
    // Open My Toy Page
    toyManager.openMyToysDialog()
    
sendCommand
  • Description

    Send toy command.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    commandobjectYesToy command, for the reference about the toy command API, please check: Standard API
    successfunctionNoCallback function for successful API call
    failfunctionNoCallback function for failed API call

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringSuccess code

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError message
  • Example

    const toyManager = appGallery.getToyManager()
    
    // Send toy command
    toyManager.sendCommand({
      command: {
        command: "Function",
        action: "Vibrate:16",
        timeSec: 20.28,
        loopRunningSec: 9.2,
        loopPauseSec: 4.3,
        stopPrevious: 1,
        toy: "",
        apiVer: 1,
      },
      success(res) {
        console.log(res.code)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
startFeedbackMode
  • Description

    Start toy feedback mode. About the toy feedback mode, please check: Toy Events API

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    toyIdListArrayNoArray of toy MAC addresses. If not provided, it will start feedback mode for all connected supported toys
    successfunctionNoCallback function triggered when the feedback mode is successfully started
    failfunctionNoCallback function triggered when the API call fails

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    typestringEvent type
    toyIdstringToy MAC address
    dataobjectEvent data

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError message
  • Example

    const toyManager = appGallery.getToyManager()
    
    // Start feedback mode
    toyManager.startFeedbackMode({
      toyIdList: ["d802de4cd35b"],
      success(res) {
        console.log(res.type)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
stopFeedbackMode
  • Description

    Stop toy feedback mode.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    toyIdListArrayNoArray of toy MAC addresses. If not provided, it will stop feedback mode for all connected supported toys.
    successfunctionNoCallback function triggered when the feedback mode is successfully stopped
    failfunctionNoCallback function triggered when the API call fails

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    typestringEvent type
    toyIdstringToy MAC address
    dataobjectEvent data

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError message
  • Example

    const toyManager = appGallery.getToyManager()
    
    // Stop feedback mode
    toyManager.stopFeedbackMode({
      toyIdList: ["d802de4cd35b"],
    })
    

Toy List

When use getMyToysInfo to get toy list or use onMyToysChange to listen toy list change, will get toy list data.

For each item in a toy list are as follows:

AttributeTypeIntroduction
showNamestringToy Name
aliasstringToy Alias, empty string if not available
firmwareVersionstringToy Firmware Version
typestringToy Type, lowercase letters
toyIdstringToy MAC Address, lowercase letters, e.g. 6c5cb14619b1
batterystringToy Battery Level, percentage value without the percentage sign
statusstringToy Connection Status ("-1": Disconnected, "0": Connecting, "1": Connected)
isSupportFeedbackModebooleanToy Feedback Mode Support (true/false)

Device

Device Manager

Use appGallery.getDeviceManager() to get the globally unique device manager instance.

setScreenOrientation
  • Description

    Set screen orientation.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    orientationstringYesScreen orientation, portrait: "portrait", landscape: "landscape"
    successfunctionNoCallback function triggered when the API call successes
    failfunctionNoCallback function triggered when the API call fails

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringSuccess code

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError message
  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Set screen orientation
    deviceManager.setScreenOrientation({
      orientation: "landscape",
      success(res) {
        console.log(res.code)
      },
      fail(err) {
        console.error(res.code)
        console.error(res.msg)
      },
    })
    
vibrateShort
  • Description

    Trigger a short vibration on the phone (around 15ms)

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    typestringYesVibration intensity type, valid values are: heavy, medium, light
    successfunctionNoCallback function triggered when the API call successes
    failfunctionNoCallback function triggered when the API call fails

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringSuccess code
  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Short vibration
    deviceManager.vibrateShort({
      type: "heavy",
      success(res) {
        console.log(res.code)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
vibrateLong

Trigger a long vibration on the phone (400ms)

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    successfunctionNoCallback function triggered when the API call successes
    failfunctionNoCallback function triggered when the API call fails
  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Long vibration
    deviceManager.vibrateLong({
      success(res) {
        console.log(res.code)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
getCurrentAccelerometer
  • Description

    Get the current accelerometer data.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    successfunctionNoCallback function triggered when the API call successes
    failfunctionNoCallback function triggered when the API call fails

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    xstringx-axis acceleration
    ystringy-axis acceleration
    zstringz-axis acceleration
    timestampstringTimestamp when the data was obtained
  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Get the current accelerometer data
    deviceManager.getCurrentAccelerometer({
      success(res) {
        console.log(res)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
startAccelerometerListener
  • Description

    Start accelerometer listener.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    intervalstringnormalNoListen the execution frequency of the accelerometer data callback function. Valid values are: game, ui, normal. When an invalid value is passed, normal is used
    successfunctionNoCallback function triggered when the accelerometer listener is successfully enabled
    failfunctionNoCallback function triggered when the API call fails

    The interval types are as follows:

    Valid ValueIntroduction
    gameApplicable for updating game callback frequency, around 20ms per update
    uiApplicable for updating UI callback frequency, around 60ms per update
    normalNormal callback frequency, around 200ms per update

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    xstringx-axis acceleration
    ystringy-axis acceleration
    zstringz-axis acceleration
    timestampstringTimestamp when the data was obtained
  • Return

    Accelerometer listener ID

  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Start accelerometer listener
    const listenerId = deviceManager.startAccelerometerListener({
      interval: "ui",
      success(res) {
        console.log(res)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
stopAccelerometerListener
  • Description

    Stop specified or all accelerometer listeners.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    listenerIdstringNoAccelerometer listener ID. If listenerId or object parameter is not passed, all accelerometer listeners will be stopped
  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Method 1 :
    // Start accelerometer listener and record the corresponding listenerId
    const listenerId = deviceManager.startAccelerometerListener({
      interval: "game",
      success(res) {
        console.log(res)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
    // Stop the accelerometer listener with the corresponding listenerId
    deviceManager.stopAccelerometerListener({
      listenerId: listenerId,
    })
    
    // Method 2 :
    // Start accelerometer listener, default as normal
    deviceManager.startAccelerometerListener({
      success(res) {
        console.log(res)
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
    // Stop all accelerometer listeners
    deviceManager.stopAccelerometerListener()
    
startShakeListener
  • Description

    Start the shake listener.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    successfunctionNoCallback function triggered when the shake listener is successfully started
    failfunctionNoCallback function triggered when the API call fails
  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Start Shake Listener
    deviceManager.startShakeListener({
      success() {
        console.log("shake")
      },
      fail(err) {
        console.error(err.code)
        console.error(err.msg)
      },
    })
    
stopShakeListener
  • Description

    Stop the shake listener.

  • Example

    const deviceManager = appGallery.getDeviceManager()
    
    // Stop shake listener
    deviceManager.stopShakeListener()
    

App Info

App Info Manager

Use appGallery.getAppInfoManager() to get the global unique app info manager instance.

getAppBaseInfo
  • Description

    Get Lovense Remote app base infomation.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    successfunctionNoCallback function triggered when the API call successes
    failfunctionNoCallback function triggered when the API call fails

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    SDKVersionstringThe version of App Gallery SDK
    languagestringLovense Remote app language
    accountDidUpdatebooleanThe Lovense Remote account has been updated to another one
    userInfoDidUpdatebooleanThe user information (username or portrait) has been updated

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError message
  • Example

    const appInfoManager = appGallery.getAppInfoManager()
    
    // Get Lovense Remote app information
    appInfoManager.getAppBaseInfo({
      success(res) {
        console.log(res.code)
      },
      fail(err) {
        console.error(res.code)
        console.error(res.msg)
      },
    })
    

File System

File System Manager

Use appGallery.getFileSystemManager() to get the global unique file system manager instance.

getAppBaseInfo
  • Description

    Save an image to the system album.

  • Parameters

    AttributeTypeDefaultRequiredIntroduction
    fileDatastringYesCover the image to base64 string
    successfunctionNoCallback function triggered when the API call successes
    failfunctionNoCallback function triggered when the API call fails

    Success callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringSuccess code

    Fail callback function will receive an object with the following attributes:

    AttributeTypeIntroduction
    codestringError code
    msgstringError message
  • Example

    // Define a saveImageToPhotosAlbum function
    function saveImageToPhotosAlbum() {
      // Get file system manager instance
      const fileSystemManager = appGallery.getFileSystemManager()
    
      // Save image file to photo album
      fileSystemManager.saveImageToPhotosAlbum({
        fileData: 'PiIwoN+asbHF55KjSYdIxgKp/gdn19c6teQR2EmVmQJQFQp9FVKnGv6rwU70dzOQSRHh9Q4dNq9eX+DlKkx4JRLH6hhMsRNkn+KIUxuNDR6R+f7//+6dP3pzV+DMnP',
        success(res) {
          console.log(res.code)
        },
        fail(err) {
          console.error(res.code)
          console.error(res.msg)
        },
      })
    }
    
    // Get user manager instance
    const userManager = appGallery.getUserManager()
    
    // Can be passed userManager.getAuthSetting Check to see if the user is authorized "scope.writePhotosAlbum" this scope
    userManager.getAuthSetting({
      success(res) {
        if (!res.authSetting['scope.writePhotosAlbum']) {
          userManager.authorize({
            scope: 'scope.writePhotosAlbum',
            success(res) {
              // The user has agreed that the mini-app will use the save image to photo album function, and then calls saveImageToPhotosAlbum Interface does not pop up to ask
              saveImageToPhotosAlbum()
            },
            fail(err) {
              console.error(err)
            }
          })
        } else {
          saveImageToPhotosAlbum()
        }
      },
      fail(err) {
        console.error(err)
      }
    })
    

Error Code

When the API call in the mini app fails, it will return the corresponding error code. You can refer to the following error code information to find a solution.

Common Error Code

Error CodeReturnPlatform
10000Unknown erroriOS, Android
10001Invalid parameteriOS, Android
10002Request failediOS, Android

Function Error Code

The 2&3-digit code represents the functionality. For example, 01 represents toy commands, 02 represents audio, 11 represents accelerometer, and 12 represents user information.

Error CodeReturnPlatform
20100Failed to parse dataiOS, Android
20101Command handling erroriOS
20200Audio session setup erroriOS
20201Audio recording permission not grantediOS, Android
20202Audio recorder holder does not existiOS
20203Audio recorder setup erroriOS, Android
21100Device motion not availableiOS
21101Device motion erroriOS
21102Device motion does not existiOS
21103Device motion holder does not existiOS
21104Device does not support hapticsiOS
21105Failed to initialize haptic deviceiOS
21106Device sensor errorAndroid
21107Accelerometer sensor errorAndroid
21200User login authorization cancellediOS, Android
21201User not logged into RemoteiOS, Android
21202Failed to retrieve user infoiOS, Android
21203User account list emptyiOS, Android
21204Failed to retrieve user auth codeiOS, Android
21205Privacy policy not provided. Request not allowediOS, Android
21206User denied the privacy policy. Request not allowediOS, Android
21207Lovense Remote does not have permission to save images to the user's albumiOS, Android
21208The user denied your app permission to save images to their albumiOS, Android
21209The app has not yet requested permission to save images to the user's albumiOS, Android

They represent Standard API functionality.

Error CodeReturnPlatform
30000Invalid commandiOS, Android
30001Toy not foundAndroid
30002Toy not connectediOS, Android
30003Toy does not support this commandAndroid
30004HTTP server not started or disablediOS, Android
30005No connected toy supports feedback modeiOS, Android