Skip to content

sprinthubmobile/flutter-crisp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter Crisp

pub package License: MIT Twitter: oilunabr

Connect with Crisp Chat, register a user to chat (or not) and render a chat widget.

Tested on Android and iOS.

Required setup

Min SDK version:

minSdkVersion 17

AndroidManifest.xml necessary changes:

    <application
        android:usesCleartextTraffic="true">
        ...
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <provider
            android:name="com.pichillilorenzo.flutter_inappwebview.InAppWebViewFileProvider"
            android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths" />
        </provider>
    </application>

For details check the example folder.

How to use

Initialize with:

  CrispMain crispMain;

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

    crispMain = CrispMain(
      websiteId: 'WEBSITE_ID',
      locale: 'pt-br',
    );

    crispMain.register(
      user: CrispUser(
        email: "example@provider.com",
        avatar: 'https://avatars2.githubusercontent.com/u/16270189?s=200&v=4',
        nickname: "João Cardoso",
        phone: "5511987654321",
      ),
    );

    crispMain.setMessage("Hello world");

    crispMain.setSessionData({
      "order_id": "111",
      "app_version": "0.1.1",
    });
  }

Then use with:

  • Optional clear cache.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Your brand'),
        ),
        body: CrispView(
          crispMain: crispMain,
          clearCache: false,
        ),
      ),
    );
  }

Additional parameters

You can set a chat user token via userToken

crispMain.initialize(
  websiteId: 'WEBSITE_ID',
  locale: 'pt-br',
  userToken: '<USERTOKENHERE>',
);

You can set a verification token via verificationCode More details on User Verification

crispMain.register(
  user: CrispUser(
    email: "example@provider.com",
    avatar: 'https://avatars2.githubusercontent.com/u/16270189?s=200&v=4',
    nickname: "João Cardoso",
    phone: "5511987654321",
    verificationCode: "<HMAC256CODEHERE>",
  ),
);

You can set user custom data via setSessionData more detail on Set custom data

crispMain.setSessionData({
  "order_id": "111",
  "app_version": "0.1.1",
});

Releases

No releases published

Packages

No packages published

Languages

  • Dart 67.3%
  • Ruby 26.1%
  • Kotlin 3.2%
  • Swift 3.1%
  • Objective-C 0.3%