Skip to content
LeanCloud Flutter Plugin SDK
Dart Java Swift Ruby Objective-C
Branch: master
Clone or download

Latest commit

Latest commit 18a59cd Mar 17, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea updage android sdk version Jan 25, 2020
android change date format Mar 17, 2020
example chore: update pubspec Mar 17, 2020
ios chore: rename plugin Mar 17, 2020
lib chore: tweak files organization Mar 16, 2020
test feat(dart): bridge & unit test init Dec 30, 2019
.gitignore boilerplate project Dec 19, 2019
.metadata boilerplate project Dec 19, 2019
CHANGELOG.md chore: update changelog Mar 16, 2020
LICENSE chore: tweak files organization Mar 16, 2020
README.md chore: rename plugin Mar 17, 2020
leancloud_plugin.iml updage android sdk version Jan 25, 2020
pubspec.lock chore: update pubspec Mar 17, 2020
pubspec.yaml chore: rename plugin Mar 17, 2020

README.md

leancloud_official_plugin

An official flutter plugin for LeanCloud real-time message service based on LeanCloud-Swift-SDK and LeanCloud-Java-SDK.

Flutter Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and iOS.

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

Usage

Adding dependency

  1. Following this document to add leancloud_official_plugin to your app, like this:

    dependencies:
      leancloud_official_plugin: '>=x.y.z <(x+1).0.0'    # Recommend using up-to-next-major policy.
    
  2. Using Gradle and CocoaPods to add platform-specific dependencies.

Initialization

  1. import package:leancloud_official_plugin/leancloud_plugin.dart in lib/main.dart of your project, like this:

    import 'package:leancloud_official_plugin/leancloud_plugin.dart';
  2. import cn.leancloud.AVOSCloud and cn.leancloud.AVLogger in YourApplication.java of your project, then set up ID, Key and URL, like this:

    import io.flutter.app.FlutterApplication;
    import cn.leancloud.AVOSCloud;
    import cn.leancloud.AVLogger;
    
    public class YourApplication extends FlutterApplication {
      @Override
      public void onCreate() {
        super.onCreate();
        AVOSCloud.setLogLevel(AVLogger.Level.DEBUG);
        AVOSCloud.initialize(this, YOUR_LC_APP_ID, YOUR_LC_APP_KEY, YOUR_LC_SERVER_URL);
      }
    }
  3. import LeanCloud in AppDelegate.swift of your project, then set up ID, Key and URL, like this:

    import Flutter
    import LeanCloud
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -> Bool {
        do {
          LCApplication.logLevel = .all
          try LCApplication.default.set(
            id: YOUR_LC_APP_ID,
            key: YOUR_LC_APP_KEY,
            serverURL: YOUR_LC_SERVER_URL)
          GeneratedPluginRegistrant.register(with: self)
          return super.application(application, didFinishLaunchingWithOptions: launchOptions)
        } catch {
          fatalError("\(error)")
        }
      }
    }

Run

After initialization, you can write some sample code and run it to check whether initializing success, like this:

// new an IM client
Client client = Client(id: CLIENT_ID);
// open it
await client.open();
You can’t perform that action at this time.