wisesdk 0.1.7 copy "wisesdk: ^0.1.7" to clipboard
wisesdk: ^0.1.7 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';
import 'dart:io' show Platform;

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 {
      await _wiseSdk.initSdk("650d61477aaa3e6b9988934f", "yellowmonkey");

      if (Platform.isIOS) {
        // set screen share group id and bundle id
        _wiseSdk.enableScreenShare("group.live.wise.wisesdkExample", "live.wise.wisesdkExample.screen");
      }

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

      // join meeting by classroom public ID
      // This doesn't need Authentication or SSO Login
      final joinParams = {
        "classroomPublicId": "65953bb0aa3f4e26b047982b51053399",
        "userName": "John",
        "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("eyJhbGciOppJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NTk1NTJjZWFhM2Y0ZWY0NWI0OTI4ZGEiLCJuYW1lIjoiSnlvdGhzbmEiLCJ0eXBlIjoiU0VTU0lPTl9UT0tFTiIsImlhdCI6MTcyOTY4OTYzOCwiZXhwIjoxNzM3NDY1NjM4fQ.5Q-_R2g3olOEjAAuzpEyiyVT-Gdv7WsVK1OpOwW_GWs");

      // 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'),
        ),
      ),
    );
  }
}