ali_iot_plugin 0.0.3 copy "ali_iot_plugin: ^0.0.3" to clipboard
ali_iot_plugin: ^0.0.3 copied to clipboard

阿里飞燕平台(生活物联网平台) Flutter plugin.封装Android和iOS SDK功能

ali_iot_plugin #

阿里飞燕平台 (生活物联网平台) Flutter plugin.

基于阿里生活物联网平台的Android和iOS架包实现的Flutter插件,方便开发自有APP

特别注意,本插件不提供飞燕项目中的插件功能,因为插件功能实际上是使用React Native 开发的UI,既然需要使用Flutter开发界面,则无需使用到该功能

Get started #

Add dependency #

dependencies:
  ali_iot_plugin: ^0.0.3 #请使用pub上的最新版本
  1. Android
  • AppApplication 需要继承 IotApplication()
  • 按照生活物联网平台 集成安全图片
  • 可能需要集成 implementation 'com.facebook.android:facebook-android-sdk:8.0.0'
  1. iOS
# github 官方 pod 源
source 'https://github.com/CocoaPods/Specs.git' 

# 阿里云 pod 源
source 'https://github.com/aliyun/aliyun-specs.git' 
  • 需要在AppDelegate的application方法中调用ALiAppDelegate.application(application,didFinishLaunchingWithOptions:launchOptions)
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    ALiAppDelegate.application(application,didFinishLaunchingWithOptions:launchOptions)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

What can do #

  1. 登录
  2. 第三方登录
  3. 退出登录
  4. 请求API通道接口
  5. 配网设备
  6. 查看设备属性
  7. 设置设备属性

Super simple to use #

import 'package:ali_iot_plugin/index.dart';

CommonAPI.logout();
CommonAPI.authCodeLogin(authCode);

DispatchNetAPI.startDiscovery(callback);
DispatchNetAPI.stopDiscovery();
DispatchNetAPI.startAddDevice(callback);
DispatchNetAPI.stopAddDevice();
DispatchNetAPI.listenGatewayPermit(callback);
DispatchNetAPI.stopListenGatewayPermit();

DevicePanelAPI.getDevicePanelProperties()
DevicePanelAPI.setDevicePanelProperties({"items": params, "iotId": iotId})
DevicePanelAPI.getDevicePanelStatus()

static Future<dynamic> requestApi(
    String path,
    String apiVersion, {
    String scheme,
    String host,
    String authType,
    String mockType,
    Map<String, Object> params,
    Map<String, Object> addParam,
    bool handleTimeOut = true,
  }) async {
      return await CommonAPI.requestApi(path, apiVersion,
              scheme: scheme, host: host, authType: authType, mockType: mockType, params: params, addParam: addParam)
          .then((value) => value, onError: (error) {
        print(error);
        if (handleTimeOut && error is PlatformException) {
          if (error.code.contains("timeout") || error.message.contains("timeout") || error.message.contains("Unable to resolve host")) {
            //请求超时
          }
        }
        throw e;
      });
   
  }

This project is a starting point for a Flutter plug-in package, 阿里飞燕 生活物联网平台 includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Todo List #

目前iOS平台只实现了部分功能,后续待完善

0
likes
105
pub points
0%
popularity

Publisher

unverified uploader

阿里飞燕平台(生活物联网平台) Flutter plugin.封装Android和iOS SDK功能

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on ali_iot_plugin