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

outdated

Smooch resources on Flutter

example/lib/main.dart

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

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);
  }

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

  Future<void> initPlatformState() async {
    try {
      await SmoochPlugin.initialize(
          appId: "5c041af62c4b1c002121dfff",
          userId: "386099",
          smoochToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImFwcF81YzA0MWIyOTQzYWVhNjAwMjI1MDVjYjMifQ.eyJzY29wZSI6ImFwcFVzZXIiLCJ1c2VySWQiOiIzODYwOTkiLCJpYXQiOjE1NzI5OTM1NTh9.e0LOQC9CJWbnuyb4jG2LDEVEkegOgUdywfktBPPhyd4",
          //onUpdateUnreadCount: _updateUnreadCount,
          //onHandleMessageAction: _handleMessageAction,
          //onShouldSendStart: _shouldStart
      );
    } on PlatformException {}
  }

  Future<void> showSmooch() async {
    try {
      await SmoochPlugin.show();
    } on PlatformException {}
  }

  @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