ttlock_flutter 0.0.8
ttlock_flutter: ^0.0.8 copied to clipboard

The ttLock flutter plugin that used to controle smart lock and gateway.

Developers Email list #

ttlock-developers-email-list@googlegroups.com

ttlock_flutter #

Config

iOS:

  1. In XCode,Add KeyPrivacy - Bluetooth Peripheral Usage Description Value your description for bluetooth to your project's infoCustom iOS Target Projectes

Android: AndroidManifest.xml configuration:

  1. add 'xmlns:tools="http://schemas.android.com/tools"' to
  2. add 'tools:replace="android:label"' to
  3. additional permissions:
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  1. in MainActivity extends FlutterActivity, you need add permissions result to ttlock plugin.

first add import

import com.ttlock.ttlock_flutter.TtlockFlutterPlugin

second add below callback code:
java code:

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        TtlockFlutterPlugin ttlockflutterpluginPlugin = (TtlockFlutterPlugin) getFlutterEngine().getPlugins().get(TtlockFlutterPlugin.class);
        if (ttlockflutterpluginPlugin != null) {
            ttlockflutterpluginPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }

kotlin code:

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
        val ttlockflutterpluginPlugin = flutterEngine!!.plugins[TtlockFlutterPlugin::class.java] as TtlockFlutterPlugin?
        ttlockflutterpluginPlugin?.onRequestPermissionsResult(requestCode, permissions, grantResults)
    }

5.you need config buildTypes in build.gradle file.like this:

    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
        }
    }
Ussage
import 'package:ttlock_flutter/ttlock.dart';

// Print TTLock Log
TTLock.printLog = true;

TTLock.controlLock(lockData, TTControlAction.unlock,(lockTime, electricQuantity, uniqueId) {
    print('success');
}, (errorCode, errorMsg) {
    print('errorCode');      
});

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

void unlockAndGetLogAndSetTime() {

     //unlock
    TTLock.controlLock(lockData, TTControlAction.unlock,(lockTime, electricQuantity, uniqueId) {
        print('success');
    }, (errorCode, errorMsg) {
        print('errorCode');      
    });
    
     //get log
    TTLock.getLockOperateRecord(TTOperateRecordType.latest, lockData,(operateRecord) {
        print('$operateRecord');
    }, (errorCode, errorMsg) {
        print('errorCode');
    });
     //set time
    int timestamp = DateTime.now().millisecondsSinceEpoch;
    TTLock.setLockTime(timestamp, lockData, () {
        print('$timestamp');
    }, (errorCode, errorMsg) {
        print('errorCode');
    });
}

How to determine the function of a lock
 TTLock.supportFunction(TTLockFuction.managePasscode, lockData,(isSupport) {
    if (isSupport) {
        TTLock.modifyPasscode("6666", "7777", startDate, endDate, lockData,() {
            print('success');
        }, (errorCode, errorMsg) {
            print('errorCode');
        });
    } else {
        print('Not support modify passcode');
    }
});
3
likes
90
pub points
62%
popularity

Publisher

Unknown

The ttLock flutter plugin that used to controle smart lock and gateway.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on ttlock_flutter