flutter_freshchat 1.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

💬 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>
  1. At this point if you try to build you will get an error something related to duplicate info.plist (Note: It's something to do with Freshchat) you can remove this info by following the below instructions:
  • Open your .xcworkspace in xcode.
  • Goto to Pods.
  • Select target flutter_freshchat.
  • Select Build Phases and then go to Compile Sources.
  • Look for two info.plist entries and remove them.

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 = "jhon@test.com";
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!

1.2.1 #

  • Freshchat android dependency updated to version 2.9.0 from 2.4.1

1.2.0 #

  • Documentation updated

1.1.8 #

  • IOS crash fixed

1.1.7 #

  • Small type casting issues fixed with IOS plugin

1.1.6 #

  • Meta dependency removed & updated the example

1.1.5 #

  • A type checking issue in IOS plugin while updating use info fixed

1.1.4 #

  • Use application instead of activity to avoid duplicate applications

1.1.3 #

  • Fixed as issue with Map class not being imported in android

1.1.2 #

  • Added a customProperties field to the updateUserInfo method
  • Added support for IOS

1.1.1 #

  • Camera enabled option added

1.1.0 #

  • Added support for all user properties
  • Fixed an issue where installing the same plugin on multiple app would not allow the other app to install due to same ContentProvider was being used

1.0.0 #

  • Added support for IOS

0.0.3 #

  • MIT License added

0.0.2 #

  • README.md updated with links

0.0.1 #

  • Initial Release

example/README.md

flutter_freshchat_example #

Demonstrates how to use the flutter_freshchat plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_freshchat: ^1.2.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_freshchat/flutter_freshchat.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

31 out of 31 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test