smooch_plugin 1.0.13 copy "smooch_plugin: ^1.0.13" to clipboard
smooch_plugin: ^1.0.13 copied to clipboard

outdated

Smooch resources on Flutter

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:smooch_plugin/smooch_plugin.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _count = -1;

  bool _shouldStart() {
    return true;
  }

  void _updateUnreadCount(count) {
    setState(() {
      _count = count;
    });
  }

  void _handleMessageAction(uri) {
    print(uri);
  }

  void _logoutComplete(logoutResult) {}

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

    initPlatformState();
  }

  Future<void> initPlatformState() async {
    try {
      await SmoochPlugin.init(
//          appId: "5a03043874d36900511723cc",
//          userId: "387588",
//          smoochToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImFwcF81YmIzN2QzOGMyYzIwMTAwMjI3M2YyMjgifQ.eyJzY29wZSI6ImFwcFVzZXIiLCJ1c2VySWQiOiIzODc1ODgiLCJpYXQiOjE1NzQzNDM3NDl9.iSKCflihoeMjUOOK8b3nTELIrHvJiPVFEnO7ufXzjRU",
//          appId: "5c041af62c4b1c002121dfff",
          appId: "5a03043874d36900511723cc",
          userId: "387588",
          smoochToken:
              "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImFwcF81YmIzN2QzOGMyYzIwMTAwMjI3M2YyMjgifQ.eyJzY29wZSI6ImFwcFVzZXIiLCJ1c2VySWQiOiIzODc1ODgiLCJpYXQiOjE1NzQzNDgwMjZ9.bCsUuOAc4_k8HCIIkJ7XUQM7RPPrRd23B3JIt5Z0DJA",
          onUpdateUnreadCount: _updateUnreadCount,
          onHandleMessageAction: _handleMessageAction,
          onShouldSendStart: _shouldStart,
          onLogout: _logoutComplete);
    } on PlatformException catch (e) {
      print('Exception: $e');
    }
  }

  Future<void> showSmooch() async {
    try {
      await SmoochPlugin.show("es");
    } on PlatformException catch (e) {
      print('Exception: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Smooch plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              FlatButton(
                onPressed: showSmooch,
                child: Text("Abrir smooch"),
              ),
              Text('Unread messages count: $_count')
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Smooch resources on Flutter

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on smooch_plugin