Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fayeed/flutter_freshchat
The unofficial flutter plugin for Freshchat
https://github.com/fayeed/flutter_freshchat
conversation flutter flutter-plugin freshchat
Last synced: 3 months ago
JSON representation
The unofficial flutter plugin for Freshchat
- Host: GitHub
- URL: https://github.com/fayeed/flutter_freshchat
- Owner: fayeed
- License: mit
- Archived: true
- Created: 2019-04-16T12:17:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-27T13:18:15.000Z (over 2 years ago)
- Last Synced: 2024-04-03T09:33:49.120Z (7 months ago)
- Topics: conversation, flutter, flutter-plugin, freshchat
- Language: Dart
- Homepage: https://pub.dartlang.org/packages/flutter_freshchat
- Size: 24.1 MB
- Stars: 32
- Watchers: 3
- Forks: 36
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
💬 Flutter Freshchat
A Flutter plugin for integrating Freshchat in your mobile app.## Setup
### Android
Add this to your `AndroidManifest.xml`
```xml
```
If you have migrated to AndroidX your might need change the provider attribute `android:name` to this:
```xml
```
Add this to your `Strings.xml` located inside `android/src/res/values`
```xml
com.example.demoapp.provider
```**Firebase Cloud Messaging support**
1. Add dependency in `/android/app/build.gradle`
```gradle
dependencies {
implementation "com.github.freshdesk:freshchat-android:3.3.0"
}
```2. Create `FreshchatMessagingService.java` (Java, not Kotlin) class to your app in the same directory as your `MainActivity` class
```java
package com.example.app;import com.freshchat.consumer.sdk.Freshchat;
import com.google.firebase.messaging.RemoteMessage;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;public class FreshchatMessagingService extends FlutterFirebaseMessagingService {
@Override
public void onNewToken(String token) {
super.onNewToken(token);
}@Override
public void onMessageReceived(final RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (Freshchat.isFreshchatNotification(remoteMessage)) {
Freshchat.handleFcmMessage(this, remoteMessage);
}
}
}
```3. In `AndroidManifest.xml` add
```xml
```
4. In your `Application` class change
```java
FlutterFirebaseMessagingService.setPluginRegistrant(this)
```
to
```java
FreshchatMessagingService.setPluginRegistrant(this)
```### IOS
1. Add this to info.plist
> Starting with iOS 10, Apple requires developers to declare access to privacy-sensitive controls ahead of time.```xml
NSPhotoLibraryUsageDescription
To Enable access to Photo Library
NSCameraUsageDescription
To take Images from Camera
```2. If you encounter `non-modular header` error during project build
```bash
error: include of non-modular header inside framework module 'flutter_freshchat.FlutterFreshchatPlugin'
```> - Manually in xcode update the FreshchatSDK.h to be in the flutter_freshchat target and public.
You may have to do this each time your switch or rebuild the xcode project from flutter.## Usage
To use this plugin, add `flutter_freshchat` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
```dart
import 'package:flutter_freshchat/flutter_freshchat.dart';
```Initialize the Freshchat app with `appID`, `appKey` & `domain` which you could get from here: [Where to find App ID and App Key](https://support.freshchat.com/support/solutions/articles/229192)
It has following [FreshchatConfig] properties:- `domain` Each Freshchat cluster falls in to one of this domains:
- US - https://msdk.freshchat.com (default)
- AU - https://msdk.au.freshchat.com
- EU - https://msdk.eu.freshchat.com
- IN - https://msdk.in.freshchat.com
- US2 - https://msdk.us2.freshchat.com- `cameraEnabled` property is used to either enable or disable camera
within freshchat conversation widget. It default value is set to `true`.- `gallerySelectionEnabled` property is used to either enable or disable gallery
within freshchat conversation widget. It default value is set to `true`.- `teamMemberInfoVisible` property is used to show team member info
within freshchat conversation widget. It default value is set to `true`.- `responseExpectationEnabled` property is used to show exceptions that occur
within freshchat conversation widget. It default value is set to `true`.- `showNotificationBanner` property is used enabled or disable in-app notification
banner. It default value is set to `true`. (NOTE: IOS only).- `notificationSoundEnabled` property is used enabled or disable in-app notification
sound. It default value is set to `true`. (NOTE: IOS only).```dart
await FlutterFreshchat.init(
appID: 'YOUR_APP_ID_HERE',
appKey: 'YOUR_APP_KEY_HERE',
domain: 'https://msdk.freshchat.com'
);
```Update the user info by setting by creating a `FreshchatUser` object
```dart
FreshchatUser user = FreshchatUser.initial();
user.email = "[email protected]";
user.firstName = "john";
user.lastName = "doe";
user.phoneCountryCode = "+91";
user.phone = "0123456789";await FlutterFreshchat.updateUserInfo(user: user);
// Custom properties can be set by creating a Map
Map customProperties = Map();
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```dart
await FlutterFreshchat.identifyUser(externalID: 'USER_UNIQUE_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 the chat screen.
```dart
await FlutterFreshchat.showConversations(tags: const [], title: 'CHAT_SCREEN_TITLE');
```Send message directly within the app without opening the Freshchat interface. `tag` is optional.
```dart
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````dart
await FlutterFreshchat.showFAQs();
```Gets the unseen message count from freshchat you can use this to show a counter.
```dart
int count = await FlutterFreshchat.getUnreadMsgCount();
```Reset user data at logout or when deemed appropriate based on user action in the app.
```dart
await FlutterFreshchat.resetUser();
```## Example
Find the example wiring in the [Flutter_Freshchat example application](https://github.com/fayeed/flutter_freshchat/blob/master/example/lib/main.dart).
## API details
See the [flutter_freshchat.dart](https://github.com/fayeed/flutter_freshchat/blob/master/lib/flutter_freshchat.dart) for more API details
## Issues and feedback
Please file [issues](https://github.com/fayeed/flutter_freshchat/issues)
to send feedback or report a bug. Thank you!