💬 Flutter Freshchat
A Flutter plugin for integrating Freshchat in your mobile app.
Add this to your
<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>
If you have migrated to AndroidX your might need change the provider attribute
android:name to this:
<provider android:name="androidx.core.content.FileProvider"> </provider>
Add this to your
Strings.xml located inside
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
use_frameworks!at the top of your Podfile.
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>
To use this plugin, add
flutter_freshchat as a dependency in your pubspec.yaml file.
Initialize the Freshchat app with
appKey which you could get from here: Where to find App ID and App Key<br/><br/>
It has following
cameraEnabledproperty is used to either enable or disable camera within freshchat conversation widget. It default value is set to
gallerySelectionEnabledproperty is used to either enable or disable gallery within freshchat conversation widget. It default value is set to
teamMemberInfoVisibleproperty is used to show team member info within freshchat conversation widget. It default value is set to
responseExpectationEnabledproperty is used to show exceptions that occur within freshchat conversation widget. It default value is set to
showNotificationBannerproperty is used enabled or disable in-app notfication banner. It default value is set to
true. (NOTE: IOS only).
notificationSoundEnabledproperty is used enabled or disable in-app notfication sound. It default value is set to
true. (NOTE: IOS only).
await FlutterFreshchat.init(appID: 'YOUR_APP_ID_HERE', appKey: 'YOUR_APP_KEY_HERE');
Update the user info by setting by creating a
FreshchatUser user = FreshchatUser.initail(); user.email = "email@example.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');
Send message directly within the app without opening the Freshchat interface.
tag is optional.
await FlutterFreshchat.send(message: 'YOUR_MESSAGE_HERE', tag: 'YOUR_TAG_HERE');
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
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.
Find the example wiring in the Flutter_Freshchat example application.
See the flutter_freshchat.dart for more API details
Issues and feedback
Please file issues to send feedback or report a bug. Thank you!