zonkafeedback_sdk 1.3.1
zonkafeedback_sdk: ^1.3.1 copied to clipboard
A Flutter plugin for seamless feedback collection and management with Zonka Feedback.
Zonka Feedback Flutter SDK #
Pre-Requisites #
The Zonka Feedback Flutter SDK requires:
- Zonka Feedback Account: An active Zonka Feedback account.
- SDK Token: Obtain this token for the survey you want to implement:
- Create a Zonka Feedback account.
- Create a new survey with the desired questions.
- Navigate to the Distribute menu → In-App tab.
- Enable the toggle to view your SDK token.
Follow the steps below to integrate the SDK into your app.
Learn more about creating surveys on Zonka Feedback.
Minimum Requirements #
- Flutter: Version 3.7.0 or higher.
- Android:
- CompileSdk version: 34 or higher.
- Android Gradle Plugin: 8.1.0 or higher.
- iOS: iOS 14 or higher.
Installation #
Add the Zonka Feedback SDK as a dependency in your pubspec.yaml file:
dependencies:
zonkafeedback_sdk: <latest_version>
Configuration #
Configuration for iOS : Add the following snippet to your Info.plist file.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Initialization #
Initialize the SDK in your app's main file (e.g., lib/main.dart):
import 'package:zonkafeedback_sdk/zonkafeedback_sdk.dart';
class _ZonkaFeedBackSurveyState extends State<ZonkaFeedBackSurvey> with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
ZFSurvey().init(
token: ['{{SDK_TOKEN}}'], // Replace with your SDK token
zfRegion: '{{REGION}}', // Options: US, EU, IN
context: context,
closeIconType: 'icon2',
minimumHeight: 410,
closeIconPosition: "right",
expandedHeight: 580,
autoClose:false
);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
ZFSurvey().sendAppLifecycleState(state);
super.didChangeAppLifecycleState(state);
}
}
Survey Display Configuration options #
To configure the display type for the survey, use one of the following options with displayType:
-
popup
- Shows the survey as a popup in the center of the screen.
-
slide-up
- Displays the survey as a slide-up bottom sheet.
Survey Height Configuration #
-
minimum-height
- You can give minimum height to survey ui slide-up and popup using key
minimumHeight.
- You can give minimum height to survey ui slide-up and popup using key
-
expanded-height
- You can give maximum height to survey ui slide-up and popup using key
expandedHeight.
- You can give maximum height to survey ui slide-up and popup using key
Auto Close #
To configure the auto close icon for the survey, use one of the following options with autoClose:
-
autoClose
- You can set autoClose
truewhich enable survey to close automatically..
- You can set autoClose
-
autoClose
- You can set autoClose
falsewhich disable survey to close automatically.
- You can set autoClose
Close Icon Position #
To configure the close icon for the survey, use one of the following options with closeIconPosition:
-
left
- You can give position to close icon to left by using value
left.
- You can give position to close icon to left by using value
-
right
- You can give position to close icon to right by using value
right.
- You can give position to close icon to right by using value
Close Icon Type #
Two built-in close icon styles are bundled with the SDK:
-
icon1
- Minimal “X” without the circular background
-
icon2
- Circle background with an “X” (the current default across Popup and Slide-up)
Note: The current release uses icon1 by default. The ability to switch types will be introduced in an upcoming update.
Setup #
To configure and start the survey in your app:
import 'package:zonkafeedback_sdk/zonkafeedback_sdk.dart';
ZFSurvey().startSurvey();
On-Page Delay #
The survey can wait a number of seconds before appearing. This is configured
per distribution in the Zonka Feedback dashboard under In-App SDK →
Configuration → On page delay, and is delivered to the SDK as
embedSettings.trigger.after. There is no code parameter — the SDK reads
whatever the dashboard is set to.
A distribution saved before this setting existed has no delay and shows the survey immediately, as before.
The delay keeps running in the background. When the survey qualifies, the
SDK saves the time it is due. Locking the phone, switching apps, taking a call,
or even the app being killed does not reset or cancel it. Time spent in the
background counts toward the delay. If the survey falls due while the app is
in the background, it is shown as soon as the user returns. After a restart
it is picked up by init(), so call init() when the app launches. Calling startSurvey() again while a survey is
waiting does not restart its delay.
Just before showing, the SDK checks again that the widget is still active and the contact is still in the targeted segments. If not, the survey is dropped. If that check cannot reach the server, the survey stays pending and is tried again on the next resume.
Long delays usually outlast the screen that called init. Pass your app's
navigator key so the survey can be shown on whichever screen is open when it
falls due:
final navigatorKey = GlobalKey<NavigatorState>();
MaterialApp(navigatorKey: navigatorKey, ...);
ZFSurvey().init(
token: ['{{SDK_TOKEN}}'],
zfRegion: '{{REGION}}',
context: context,
navigatorKey: navigatorKey,
);
Without it, a survey whose screen has closed stays pending until a mounted context is available.
For the delay to be resumed, the host app must forward lifecycle events:
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
ZFSurvey().sendAppLifecycleState(state);
super.didChangeAppLifecycleState(state);
}
Optional Parameters #
1. Send Device Details #
Send device details (OS, version, IP address, device type) with responses. Enabled by default.
ZFSurvey().sendDeviceDetails(true);
2. Send Custom Attributes #
Add additional data (e.g., screen name, order ID) to responses.
Map<String, String> properties = {
'property1': 'value1',
'property2': 'value2',
};
ZFSurvey().sendCustomAttributes(properties);
Identifying Logged-In Visitors #
Identify users by passing their details like name, email, mobile, or unique ID:
Map<String, dynamic> properties = {
'contact_name': 'Robin James',
'contact_email': 'robin@example.com',
'contact_uniqueId': '1XJ2',
'contact_mobile': '+14234XXXX',
};
ZFSurvey().userInfo(properties);
Reset Visitor Attributes #
Clear visitor data on logout:
ZFSurvey().clear();