Surveys Plugin
note
Ensure the basic integration of the Nudge Core SDK is complete. If not, check here.
Overview
The nudge_surveyv2
package lets you add surveys to your flutter application.
Find the latest version of nudge_surveyv2
here
Step-by-Step Guide
Step 1 : Import the nudge_surveyv2
package
import 'package:nudge_surveyv2/nudge_flutter_surveys_v2.dart';
Step 2 : Initialize and add to NudgeProvider.
const nudgeSurveysUi = NudgeSurveysUi();
Once you have integrated the Nudge Core SDK, just add the above-defined variable to the list in theplugins
property of NudgeProvider
..
..
NudgeProvider(
app: nudge,
plugins: [nudgeSurveysUi]
..
..
)
Callbacks
1. Implement Nudge Callback
Implement the NudgeGCallback
in your screen:
class _HomePageState extends State<HomePage> implements NudgeGCallback {
...
}
2. Register the Callback
Register the listener in the initState method:
@Override
void initState() {
super.initState();
NudgeGCallbackManager.registerListener(this);
}
3. Listening to events
Now, you can listen and respond to events:
@Override
void onEvent(NudgeCallback event) {
if (event is NudgeSurveyCallback) {
if (event.action == "Question_Response") {
print("Survey Response ${event.data}");
}
}
}
What will you receive from the callback
Key | Description |
---|---|
campaign | Unique Id of the campaign created in the dashboard |
question_type | Type of question the callback is from. It will be either of the follows : MultipleResponseMCQ, Comment, Rating, SingleResponseMCQ |
answer | User's response to the specific question |
That's it!
Our Nudge Core would now trigger Surveys defined on your Dashboard using the survey plugin.