Code Monkey home page Code Monkey logo

flutter_freshchat's Introduction

💬 Flutter Freshchat

A Flutter plugin for integrating Freshchat in your mobile app.

Setup

Android

Add this to your AndroidManifest.xml

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="com.example.demoapp.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/freshchat_file_provider_paths" />
</provider>

Add this to your Strings.xml located inside android/src/res/values

<string name="freshchat_file_provider_authority">com.example.demoapp.provider</string>

IOS

  1. If you are using Objective-C in your flutter project then you will need to create a briging header between objective-C and swift to do that follow the steps below:
  • Bridging Header must be created.
  • Open the project with XCode. Then choose File -> New -> File -> Swift File.
  • A dialog will be displayed when creating the swift file(Since this file is deleted, any name can be used.).
  • XCode will ask you if you wish to create Bridging Header, click yes.
  • Make sure you have use_frameworks! in the Runner block, in ios/Podfile。
  • Make sure you have SWIFT_VERSION 4.2 selected in you XCode -> Build Settings
  • Do flutter clean.
  • Go to your ios folder, delete Podfile.lock and Pods folder and then execute pod install --repo-update
  1. Add use_frameworks! at the top of your Podfile.
  2. Add this to info.plist

Starting with iOS 10, Apple requires developers to declare access to privacy-sensitive controls ahead of time.

    <key>NSPhotoLibraryUsageDescription</key>
    <string>To Enable access to Photo Library</string>
    <key>NSCameraUsageDescription</key>
    <string>To take Images from Camera</string>

Usage

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

import 'package:flutter_freshchat/flutter_freshchat.dart';

Initialize the Freshchat app with appID and appKey which you could get from here: Where to find App ID and App Key
It also has cameraEnabled parameter with default value set to true.
You can disable the camera by setting it to false.

await FlutterFreshchat.init(appID: 'YOUR_APP_ID_HERE', appKey: 'YOUR_APP_KEY_HERE');

Update the user info by setting by creating a FreshchatUser object

FreshchatUser user = FreshchatUser.initail();
user.email = "[email protected]";
user.firstName = "jhon";
user.lastName = "doe";
user.phoneCountryCode = "+91";
user.phone = "0123456789";

await FlutterFreshchat.updateUserInfo(user: user);

// Custom properties can be set by creating a Map<String, String>
Map<String, String> customProperties = Map<String, String>();
customProperties["loggedIn"] = "true";

await FlutterFreshchat.updateUserInfo(user: user, customProperties: customProperties);

Identify the user user by usin email address or any way you uniquely identify the user. externalID is required and returns a restoreID you can save it and use to restore the chats

await FlutterFreshchat.identifyUser(externalID: 'USER_UNQIUE_ID', restoreID: 'USER_RESTORE_ID');

Show conversation opens a conversation screen and also list all the other conversation if a list obejct is supplied to it. You can also pass a title for teh chat screen.

await FlutterFreshchat.showConversations(tags: const [], title: 'CHAT_SCREEN_TITLE');

ShowFAQs opens a FAQ screen in a grid like format as default you can change the default setting by changing this paramters.
showFaqCategoriesAsGrid = true
showContactUsOnAppBar = true
showContactUsOnFaqScreens = false
showContactUsOnFaqNotHelpful = false

await FlutterFreshchat.showFAQs();

Gets the unseen message count from freshchat you can use this to show a counter.

int count = await FlutterFreshchat.getUnreadMsgCount();

Reset user data at logout or when deemed appropriate based on user action in the app.

await FlutterFreshchat.resetUser();

Example

Find the example wiring in the Flutter_Freshchat example application.

API details

See the flutter_freshchat.dart for more API details

Issues and feedback

Please file issues to send feedback or report a bug. Thank you!

flutter_freshchat's People

Contributors

fayeed avatar faisalabid avatar daadu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.