Skip to content

Latest commit

 

History

History
75 lines (54 loc) · 2.28 KB

README.md

File metadata and controls

75 lines (54 loc) · 2.28 KB

phyllo_connect

pub package

Phyllo Connect is a quick and secure way to connect work platforms via Phyllo in your app. Supports: iOS, Android.

Usage

To use this plugin, add phyllo_connect as a dependency in your pubspec.yaml file.

Example

Replace your

import 'package:phyllo_connect/phyllo_connect.dart';

class Configs {
  Configs._();

  static const String clientId = '<client id here>';

  static const String clientSecret = '<client secret here>';

  static const PhylloEnvironment environment = PhylloEnvironment.sandbox; //set phyllo environment
}

-> Lib -> phyllo_provider.dart

import 'package:flutter/material.dart';
import 'package:phyllo_connect/phyllo_connect.dart';
import 'package:phyllo_connect_example/client/phyllo_repository.dart';
import 'package:phyllo_connect_example/constants/configs.dart';

final PhylloConnect _phylloConnect = PhylloConnect.instance;
//Too Lunch the sdk here it will method
void _launchSdk(String workPlatformId) {

  Map<String, dynamic> config = {
      'clientDisplayName': clientDisplayName,
      'environment': PhylloEnvironment.sandbox.name,
      'userId': _userId!,
      'token': _token!,
      'workPlatformId': workPlatformId
    };

    _phylloConnect.initialize(config);
    _phylloConnect.open();
    
    //Call Back from Android/iOS SDK
    _phylloConnect.onConnectCallback(
        onAccountConnected: (account_id, work_platform_id, user_id) {
      log('onAccountConnected: $account_id, $work_platform_id, $user_id');
    }, onAccountDisconnected: (account_id, work_platform_id, user_id) {
      log('onAccountDisconnected: $account_id, $work_platform_id, $user_id');
    }, onTokenExpired: (user_id) {
      log('onTokenExpired: $user_id');
    }, onExit: (reason, user_id) {
      log('onExit: $reason, $user_id');
    },
     // [Optional callback] onConnectionFailure : User can now add a new callback connectionFailure for tracking the reason of accounts not getting connected.
        onConnectionFailure: (reason, work_platform_id, user_id) {
      log('onConnectionFailure: $reason, $work_platform_id, $user_id');
    );

    log('version: ${_phylloConnect.version()}');
    
  }