Giter VIP home page Giter VIP logo

ali_iot_plugin's Introduction

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平台只实现了部分功能,后续待完善

ali_iot_plugin's People

Contributors

cat-x avatar

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.