whelp_flutter_sdk 0.4.2 whelp_flutter_sdk: ^0.4.2 copied to clipboard
Whelp Live Chat SDK for Flutter targeting Android and iOS platforms
Whelp Live Chat for Flutter #
Whelp Flutter Live Chat Package is a Flutter library that allows you to integrate a live chat feature into your Flutter applications using the Whelp service.
For native Android and iOS applications, please refer to the Android and iOS documentation.
⚠️ Note #
Before you use the package, you must be enrolled to Whelp in order to obtain an APP_ID
and API_KEY
on which the SDK depends on to function.
🪚 Installation #
To use this package, add whelp_flutter_sdk
as a dependency in your pubspec.yaml
file:
dependencies:
flutter:
sdk: flutter
whelp_flutter_sdk: ^0.4.2
Then, run flutter pub get
in your terminal to install the package.
⚙️ Configuration #
In order to be able to use media attachments in the live chat, it's required to add the following permissions to your app's AndroidManifest.xml
for Android and Info.plist
for iOS:
Android #
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
iOS #
<key>NSCameraUsageDescription</key>
<string>Camera permission is required for live chat media attachments.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo library permission is required for live chat media attachments.</string>
Usage #
- Import the necessary libraries:
import 'package:whelp_flutter_sdk/whelp_flutter_sdk.dart';
- Create a
WhelpUser
instance with user information for authentication:
final WhelpUser user = WhelpUser(
email: 'john@doe.com',
fullName: 'John Doe',
phoneNumber: '+1234567890',
language: 'EN',
identifier: IdentityIdentifier.email,
);
- Here the
identifier
is based on which the identity and uniquness of the user is determined: if matched, previous chats of the user will be loaded, otherwise a new chat will be created. - Either of
phoneNumber
andemail
can be null. In case both of them are null you might not be able to user's previous chat history on every new launch.
- Create a
WhelpConfig
instance with yourAPP_ID
andAPI_KEY
:
final WhelpConfig config = WhelpConfig(
appId: 'your_app_id',
apiKey: 'your_api_key',
deviceId: '{fcm_token}',
disableMoreButton: true,
disableEmojiPicker: true,
disableSounds: true,
headerTitle: 'What do you want to talk us about?',
onLog: (String message) {
log(message, name: 'WHELP');
},
activeStatus: 'We are online',
awayStatus: 'We are offline',
);
- If you couldn't find your
APP_ID
andAPI_KEY
credentials on whelp platform, consider contacting the customer support on the website which is also powered by whelp 😎 - Notice that there are two optional parameters that can be used to disable the more button and emoji picker in the live chat interface.
The emoji picker is best disabled on mobile because all emojis are supported by the mobile keyboard. But if you have a good reason to enable it, you can do so by setting the
disableEmojiPicker
parameter tofalse
.
- Create a
WhelpView
widget and pass the user and config as parameters and place it in your app's widget tree:
WhelpScaffold(
appBar: AppBar(
title: Text('Whelp Live Chat'),
),
user: user,
config: config,
)
- Run the app, and the Whelp live chat interface will be displayed.
🕹️ Example #
For a more detailed example, check the example directory in this repository.
📄 License #
This package is open-source and released under the MIT License.
🙏 Contributing #
Please report any issues or feature requests on the (GitHub repository)[https://github.com/Whelp-Inc/whelp-flutter-sdk]. Contributions are welcome.