The hubspot_flutter
plugin allows you to integrate HubSpot's mobile chat SDK into your Flutter app, enabling real-time, in-app customer support for both Android and iOS.
Flutter is migrating to Swift Package Manager to manage iOS and macOS native dependencies. Flutter's support of Swift Package Manager is under development. The implementation might change in the future. Swift Package Manager support is only available with flutter on the main channel.
iOS support should only be used with flutter on the main channel.
Add hubspot_flutter
to your pubspec.yaml
file:
dependencies:
flutter:
sdk: flutter
hubspot_flutter:
git:
url: https://github.com/shuttlershq/hubspot_flutter.git
ref: dev
- Make sure your iOS deployment target is set to 15.0 or higher in your ios/Podfile.
- Add the HubSpot-Info.plist file to your iOS project under ios/Runner.
-
- Open your project /ios/Runner.xcworkspace in Xcode
open ./ios/Runner.xcworkspace
-
- In the Xcode Project Navigator, right-click on the Runner folder and select Add Files to "Runner"....
-
- Add the Hubspot-Info.plist file if it isn’t already present.
-
- In the right-hand pane, under Target Membership, make sure that the Runner target is checked to ensure the file is linked properly.
- Ensure your minSdkVersion is set to 26 or higher in your android/app/build.gradle file.
- Place your google-services.json in the android/app/ directory.
- Place your hubspot-info.json in the android/app/src/main/assets/ directory.
- Update the
AndroidManifest.xml
:
In your app’s
AndroidManifest.xml
file, ensure that you add the following line in the<application>
tag to apply the appropriate theme. You can also specify your custom app theme here
<application
android:theme="@style/Theme.AppCompat.Light"
... >
Before using any chat functionality, initialize the SDK:
import 'package:hubspot_flutter/hubspot_flutter.dart';
await HubspotFlutter.initialize();
To open the chat view, use:
await HubspotFlutter.openChat();
Identify a user with their email and identity token:
await HubspotFlutter.setUserIdentity(email: "user@example.com", identityToken: "identityToken123");
Set custom properties for the chat session:
await HubspotFlutter.setChatProperties({
"CameraPermissions": "false",
"PhotoPermissions": "false",
"NotificationPermissions": "false",
});
Clear user data on logout:
await HubspotFlutter.logout();
Refer to the example directory for a complete implementation example.
Feel free to submit issues and pull requests for improvements. Contributions to enhance the plugin's functionality are welcome.
/.../AndroidManifest.xml Error:
uses-sdk:minSdkVersion 21 cannot be smaller than version 26 declared in library [com.hubspot.mobilechatsdk:mobile-chat-sdk-android:1.0.3] /Users/codefarmer/.gradle/caches/transforms-3/cc158e89eb26b58120b42c3d31b601f0/transformed/jetified-mobile-chat-sdk-android-1.0.3/AndroidManifest.xml as the library might be using APIs not available in 21
Suggestion: use a compatible library with a minSdk of at most 21,
or increase this project's minSdk version to at least 26,
or use tools:overrideLibrary="com.hubspot.mobilesdk" to force usage (may lead to runtime failures)