wisesdk 0.1.0 copy "wisesdk: ^0.1.0" to clipboard
wisesdk: ^0.1.0 copied to clipboard

Wise meetings SDK

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:wisesdk/wisesdk.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _wiseSdk = Wisesdk();

  // channel name must by `wisesdk`
  final wiseChannelName = 'wisesdk';

  @override
  void initState() {
    super.initState();
    initPlatformState();

    final methodChannel = MethodChannel(wiseChannelName);
    methodChannel.setMethodCallHandler(_wiseSDKMeetingListener);
  }

  Future<void> initPlatformState() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      debugPrint('Hello!');
      await _wiseSdk.initSdk("650d61477aaa3e6b9988934f", "yellowmonkey");

      // enable / disable screen capture
      _wiseSdk.disableScreenCapture(false);

      // set Lens icon
      _wiseSdk.setLensIcon("lens_demo");

      // join meeting by classroom public ID
      // This doesn't need Authentication or SSO Login
      final joinParams = {
        "classroomPublicId": "65953bb0aa3f4e26b047982b51053399",
        "userName": "Ravi Flutter",
        "userId": "userId_101001"
      };

      if (await _wiseSdk.isMeetingInProgress()) {
        _wiseSdk.gotoMeeting();
      } else {
        _wiseSdk.joinMeeting(joinParams);
      }

      // SSO Login
      // await _wiseSdk.loginUsingSSOToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwaG9uZU51bWJlciI6Iis5MTgyOTc2NTg4OTMiLCJpYXQiOjE3MDQyODc1OTAsImV4cCI6MTcwNDI4NzcxMH0.kiKK66SD0XNjsjRLUBOfJ4nqEvrvekERu383umCv3Jo");

      // Logout SSO
      // _wiseSdk.logoutSSO();

      // Set Auth token
      // _wiseSdk.setAuthToken("YOUR_AUTH_TOKEN");

      // join meeting by classroom number
      // SSO Login or Auth token is needed to do this
      final joinParams1 = {
        "classroomId": "65953bb0aa3f4e26b047982b",
        "disableScreenCapture": true
      };

      if (await _wiseSdk.isMeetingInProgress()) {
        // return to in progress meeting
        _wiseSdk.gotoMeeting();
      } else {
        //_wiseSdk.joinMeeting(joinParams1);
      }
    } on PlatformException catch (err) {
      debugPrint('Error. ${err.message}, ${err.details}');
    }

    if (!mounted) return;

    setState(() {});
  }

  Future<void> _wiseSDKMeetingListener(MethodCall call) async {
    switch (call.method) {
      case "onInitialised":
        {}
      case "onMeetingConnecting":
        {
          debugPrint("Connecting to meeting!");
        }

      case "onMeetingEnded":
        {
          final userId = call.arguments;
          debugPrint("Meeting ended. UserId: $userId");
        }

      case "onMeetingEndedByHost":
        {
          debugPrint("Meeting ended by host");
        }

      case "onMeetingEndedWithError":
        {
          final data = call.arguments;
          int errorCode = data["errorCode"];
          int internalErrorCode = data["internalErrorCode"];
          String message = data["message"];

          debugPrint(
              "onMeetingEndedWithError $errorCode, $internalErrorCode, $message");
        }

      case "onMeetingNeedPasswordOrDisplayName":
        {}

      case "onMeetingNotStartedByHostError":
        {
          debugPrint("Meeting not started by host!");
        }

      case "onMeetingStarted":
        {
          final isMeetingStarted = call.arguments;
          debugPrint("Meeting started: $isMeetingStarted");
        }

      case "onSDKError":
        {
          final data = call.arguments;
          int wiseErrorCode = data["wiseErrorCode"];
          int errorCode = data["errorCode"];
          int internalErrorCode = data["internalErrorCode"];

          debugPrint(
              "onSDKError $wiseErrorCode, $errorCode, $internalErrorCode");
        }

      case "onVendorIdError":
        {
          debugPrint("Vendor Id is missing or invalid!");
        }
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Wise SDK'),
        ),
        body: const Center(
          child: Text('Wise SDK Sample'),
        ),
      ),
    );
  }
}