Git Product home page Git Product logo

52yaoer / ios_sdk_demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ttlock/ios_sdk_demo

0.0 1.0 0.0 63.18 MB

TTLock is a global provider of solutions for smart locks. We provide PCBA and softwares for lock manufactures and end users. We provide open API/SDK for developers. With these APIs/SDKs, you can develop your own applications to manage smart locks. The SDK here is for mobile app to communicate with locks via bluetooth.

License: MIT License

Ruby 0.77% Objective-C 99.23%

ios_sdk_demo's Introduction

Developers Email list

[email protected]

Minimum iOS Target:

iOS 9.0

Minimum Xcode Version:

Xcode 10.2

Installation

By Cocoapods

First, add the following line to your Podfile:
use_frameworks!
target 'YourAppTargetName' do
pod 'TTLock' #(Required)
pod 'TTLockDFU' #(Optional)( If you need to upgrade devices into your application )
pod 'TTLockGateway' #(Optional)( If you need to use Gateway )
end

Second, pod install

By Manually

1、Drag the corresponding frameworks into the project.
2、Find Target->Build Phases -> Link Binary With Libraries ,add CoreBluetooth.framework.
3、Important! Find Target->Build Settings -> Linking -> Other Linker Flags ,add -ObjC(If it already exists, there is no need to add it.)

Introduction

TTLock

TTLock has been designed to communicate with devices by mobile phone bluetooth.
TTGateway supports second generation gateway.
TTUtil provides methods to use specialValue and get type of lock.

TTLockDFU (Device Firmware Upgrade)

TTLockDFU has been designed to make it easy to upgrade devices into your application by mobile phone bluetooth.

Usage

TTLock Usage

Initialize TTLock in the method{ didFinishLaunchingWithOptions} in AppDelegate (please do not call it in an asynchronous thread)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

     [TTLock setupBluetooth:^(TTBluetoothState state) {
        NSLog(@"##############  TTLock is working, bluetooth state: %ld  ##############",(long)state);
    }];
    return YES;
}

Scene: Unlock

 [TTLock controlLockWithControlAction:TTControlActionUnlock lockData:lockData success:^(long long lockTime, NSInteger electricQuantity, long long uniqueId) {
        NSLog(@"##############  Unlock successed power: %ld  ##############",(long)electricQuantity);
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  Unlock failed errorMsg: %@  ##############",errorMsg);
    }];

If you want to get log and set time immediately after unlocking, you can do the following:

- (void)unlockAndGetLogAndSetTime{

     //unlock
    [TTLock controlLockWithControlAction:TTControlActionUnlock lockData:lockData success:^(long long lockTime, NSInteger electricQuantity, long long uniqueId) {
        NSLog(@"##############  Unlock successed power: %ld  ##############",(long)electricQuantity);
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  Unlock failed errorMsg: %@  ##############",errorMsg);
    }];
    
     //get log
    [TTLock getOperationLogWithType:TTOperateLogTypeLatest lockData:lockData success:^(NSString *operateRecord) {
        NSLog(@"##############  Log: %@  ##############",operateRecord);
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  Get log failed errorMsg: %@  ##############",errorMsg);
    }];

     //set time
    long long timestamp = [[NSDate date] timeIntervalSince1970] * 1000;
    [TTLock setLockTimeWithTimestamp:timestamp lockData:lockData success:^{
        NSLog(@"##############  Set time successed  ##############");
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  Set time failed errorMsg: %@  ##############",errorMsg);
    }];
}

How to use SpecialValue

 BOOL isSuportPasscode = [TTUtil lockSpecialValue:_lockModel.specialValue suportFunction:TTLockSpecialFunctionPasscode];
 BOOL isSuportICCard = [TTUtil lockSpecialValue:_lockModel.specialValue suportFunction:TTLockSpecialFunctionICCard];
 BOOL isSuportFingerprint = [TTUtil lockSpecialValue:_lockModel.specialValue suportFunction:TTLockSpecialFunctionFingerprint];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.