DeveloperDeveloper
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
Got Stuck?
Forum for Lovense Developers
Support
Document Feedback

iOS SDK v1.1.5

The Lovense iOS SDK is a set of application interfaces based on iOS 8.0 and above. Use this SDK to develop applications for iOS mobile devices. By calling the Lovense SDK interface, you can easily control Lovense toys and build applications with rich functions and strong interactivity.

Download Demo

Step 1: Get your developer token

Go to the developer dashboard and get your developer token.

Step 2: Download and extract the Lovense SDK

Download SDK

Step 3: Include the SDK in your project

Copy the following files to your project main directory.

Add the required framework Lovense.framework to your project.

Link Lovense iOS SDK

Configure environment: TARGETS -> General -> Deployment Info -> Deployment Target -> setting 8.0 or above.

Step 4: Connect Lovense toys and send commands

// import Lovense
#import <Lovense/Lovense.h>

// Pass your token into the Lovense framework
[[Lovense  shared] setDeveloperToken:@"Your token"];

// Add a scan success notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanSuccessCallback:)
name:kToyScanSuccessNotification object:nil];      //Scanning toy success notification
-(void)scanSuccessCallback:(NSNotification *)noti
{
    NSDictionary * dict = [noti object];
    NSArray <LovenseToy*>* toys = [dict objectForKey:@"scanToyArray"];
}

// Add a connect success notification

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(connectSuccessCallback:)
name:kToyConnectSuccessNotification object:nil];     //Connected toy successfully notification
-(void)connectSuccessCallback:(NSNotification *)noti
{
    NSDictionary * dict = [noti object];
    LovenseToy * toy = [dict objectForKey:@"toy"];
    NSLog(@"%@",toy);
}

// Search for the toys over Bluetooth
[[Lovense  shared] searchToys];

// Save the toys
[[Lovense  shared] saveToys:toys];

// Retrieve the saved toys
NSArray<LovenseToy*> * listToys = [[Lovense  shared] listToys];

// Connect the toy
[[Lovense shared] connectToy:toyId];

// Disconnect the toy
[[Lovense shared] disconnectToy:toyId];

// Send a command to the toy
[[LovenseBluetoothManager shared] sendCommandWithToyId:toyId
andCommandType:COMMAND_VIBRATE andParamDict:@{kSendCommandParamKey
_VibrateLevel:@(20)}];

Create YourProjectName-Bridging-Header.h

// Import Lovense
#import <Lovense/Lovense.h>

// Pass your token into Lovense framework
Lovense.shared().setDeveloperToken("token")

//Add a scan success notification
NotificationCenter.default.addObserver(self, selector: #selector(scanSuccessCallback),
name: NSNotification.Name(rawValue: kToyScanSuccessNotification), object: nil)
//Scanning toy success notification
@objc func scanSuccessCallback(nofi : Notification)
{
    let dict = nofi.object as? [String, LovenseToy]
    let scanToyArr = dict?["scanToyArray"]
}

//Add a connect success notification
NotificationCenter.default.addObserver(self, selector: #selector(connectSuccessCallback),
name: NSNotification.Name(rawValue: kToyConnectSuccessNotification), object: nil)
//Connected toy successfully notification
@objc func connectSuccessCallback(nofi : Notification)
{
    let dict = nofi.object as? [LovenseToy]
    let toy = dict?["toy"]
}

// Search the toys over Bluetooth
Lovense.shared().searchToys()

//Save the toys
Lovense.shared().save(toys)


// Retrieve the saved toys
Lovense.shared().listToys()

// Connect the toy
Lovense.shared().connectToy("toyId")

// Disconnect the toy
Lovense.shared().disconnectToy("toyId")

// Send a command to the toy
Lovense.shared().sendCommand(withToyId: "ToyId",
andCommandType: COMMAND_VIBRATE,
andParamDict: [kSendCommandParamKey_VibrateLevel:20])

Command list

CommandDescription
COMMAND_VIBRATEVibrate the toy. The parameter must be between 0 and 20.
COMMAND_ROTATERotate the toy. The parameter must be between 0 and 20.
COMMAND_ROTATE_CLOCKWISERotate clockwise. The parameter must be between 0 and 20.
COMMAND_ROTATE_ANTI_CLOCKWISERotate anti-clockwise. The parameter must be between 0 and 20.
COMMAND_ROTATE_CHANGEChange the rotation direction
COMMAND_AIR_INAirbag inflation for n seconds. The parameter must be between 1 and 3.
COMMAND_AIR_OUTAirbag deflation for n seconds. The parameter must be between 1 and 3.
COMMAND_AIR_AUTOCycle airbag inflation for n seconds and air deflation for n seconds. The parameter must be between 0 and 3 (0 means stop).
COMMAND_VIBRATE1Activate the first vibrator at level n. The parameter must be between 0 and 20.
COMMAND_VIBRATE2Activate the second vibrator at level n. The parameter must be between 0 and 20.
COMMAND_VIBRATE_FLASHVibrate the toy at level n and flash the light at the same time.
COMMAND_FLASHFlash the light 3 times
COMMAND_LIGHT_OFFTurn off the light (saved permanently).
COMMAND_LIGHT_ONTurn on the light (saved permanently).
COMMAND_GET_LIGHT_STATUSGet the light's status (1: on, 0: off)
COMMAND_ALIGHT_OFFTurn off Domi/Domi 2 light (saved permanently)
COMMAND_ALIGHT_ONTurn on the Domi/Domi 2 light (saved permanently)
COMMAND_GET_ALIGHT_STATUSGet the Domi/Domi 2 light status (1: on, 0: off)
COMMAND_GET_BATTERYGet battery status
COMMAND_GET_DEVICE_TYPEGet device/toy information
COMMAND_START_MOVEStart tracking the toy movement (0-4)
COMMAND_STOP_MOVEStop tracking the toy movement
COMMAND_PRESETVibrate with a preset pattern. Patterns range from 1 to 10. n=0 will stop vibrations.
COMMAND_FLEXER_VIBRATEControl the vibration of Flexer. The parameter must be between 0 and 20.
COMMAND_FLEXER_FINGERControl the fingering motion of Flexer. The parameter must be between 0 and 20.
COMMAND_VIBRATE3Activate the third vibrator at level n. The parameter must be between 0 and 20.
COMMAND_THRUSTThrust the toy. The parameter must be between 0 and 20.
COMMAND_MULTIPLYControl three vibrators with different strength level for Lapis. Level range is 0 - 20, set level to -1 for remaining strength level from previous function.

Callback list

CallbackDescription
kToyScanSuccessNotificationFound toys
kToyConnectSuccessNotificationToy connected
kToyConnectFailNotificationFailed to connect a toy
kToyConnectBreakNotificationToy disconnection
kToySendCommandErrorNotificationUnknown command received
kToyCallbackNotificationBatteryBattery status
kToyCallbackNotificationDeviceTypeDevice information
kToyCallbackNotificationGetLightStatusLight indicator
kToyCallbackNotificationGetAidLightStatusDomi/Domi 2 light indicator
kToyCallbackNotificationListenMoveToy movement updates
kToyCommandCallbackNotificationAtSuccessSuccessful command
kToyCommandCallbackNotificationAtErrorCommand error

Sync to Lovense patterns

After completing the Native SDK integration, you can easily build features that enable users to sync Lovense toys with media by utilizing the Pattern Playback methods. Support iOS 8.0 and above.

Step 1: Initialization

Initialize the pattern player. Call this method every time you start to use the pattern syncing feature.

Note: This method only needs to be called once during the whole process.

ParametersDescriptionTypeRequired
toyIdsThe list of connected toys’ id.NSArrayRequired
pfYour platform’s name. Contact us if you aren’t sure about this.NSStringRequired
[Lovense.shared setupPatternPlayerWithToyIds: [ @toyIds] pf:@"your platform"];
Lovense.shared().setupPatternPlayer(withToyIds: [toyIds], pf: "your platform")

Step 2: Load Pattern

Load the pattern of the media to be played. Call this method every time you start to use the pattern syncing feature or when there is a change in the toy list.

ParametersDescriptionTypeRequired
mediaIDThe media’s ID from your platform.NSArrayRequired
typedef NS_ENUM(NSUInteger, PatternPrepareState) {
   PatternPrepareStateDownloading, // Pattern downloading
   PatternPrepareStateDownloadCompleted, // Pattern download completed
   PatternPrepareStateDownloadFail // Pattern download failed
};

(void)prepareForPatternWithMediaID: (NSString*) mediaID completion: (void(^)(PatternPrepareState));

Example

_weak typeof (self) weakSelf = self;
    [Lovense.shared prepareForPatternWithMediaID:weakSelf.mediaId completion:^(PatternPrepareState state) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        if (state == PatternPrepareStateDownloading) {
            // ...
        } else if (state == PatternPrepareStateDownloadCompleted) {
            // play pattern
            [Lovense.shared playPatternWithCurrentTime:[strongSelf currentTime] andTotalTime:[strongSelf totalTime]];
        } else if (state == PatternPrepareStateDownloadFail) {
            // do something
            UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"notice" message:@"pattern download fail" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction * action1 = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil];
            [alert addAction:action1];
            [strongSelf presentViewController:alert animated:true completion:nil];
        }
    }];

Lovense.shared().prepareForPattern(withMediaID: "your mediaId") { preparState in
            if preparState == .downloading {
                // ...
            } else if preparState == .downloadCompleted {
                Lovense.shared() .playPattern(withCurrentTime: currentTime, andTotalTime: totalTime)
            } else if preparState == .downloadFail {
                // ...
            }
}

Step 3: Play Pattern

ParametersDescriptionTypeRequired
currentTimeThe playing time duration so far. The default is 0. (in ms)NSTimeIntervalOptional
totalTimeThe total time of media. (in ms)NSTimeIntervalRequired
[Lovense.shared playPatternWithCurrentTime: 0 andTotalTime: 300000];
Lovense.shared() .playPattern(withCurrentTime: 0, andTotalTime: 300000)

Step 4: Sync with Media

If the rate or progress changes while playing the media, call the following methods to re-sync the rate and time.

ParametersDescriptionTypeRequired
rateThe playback rate. The default is 1.0.CGFloatOptional
[Lovense.shared setRate: 1.0];

Lovense.shared().setRate(1.0)
ParametersDescriptionTypeRequired
currentTimeThe playing time duration so far. (in ms)NSTimeIntervalRequired
[Lovense.shared syncCurrentTime: 20000];
Lovense.shared().syncCurrentTime(20000)

Pause the pattern when the media is paused or loading, so the toy’s reaction matches the media content.

[Lovense.shared  pausePattern];
 Lovense.shared().pausePattern()

Calling this method will pause the playing and reset the time to 0.

[Lovense.shared  stopPattern];
Lovense.shared().stopPattern()
Last Updated:
Explore our Forum or Support to get more inspiration or solve your problems.
Discord Channel
It is an online real-time channel where you can communicate directly with our official administrators or many excellent developers.
Forum
It is a place for Lovense developers to communicate, where you can find solutions to problems or get inspired for your projects.
Support
Find documents and tutorials that may be helpful to you.