Skip to main content
Version: Flutter SDK

Hooks

Set hooksโ€‹

You can define custom hooks to be executed on various events.

Thanks to this you will be able to interact with your application when a survey appears, or execute some custom code when a survey is submitted.

You can define hooks on PluginScreeb.initSdk(), PluginScreeb.startSurvey(), and PluginScreeb.startMessage() commands. Hooks are all optional.

Available hooksโ€‹

Hook NameAvailable on PluginScreeb.initSdk()Available on PluginScreeb.startSurvey()Available on PluginScreeb.startMessage()
onSurveyShowedYes โœ…Yes โœ…Yes โœ…
onSurveyStartedYes โœ…Yes โœ…Yes โœ…
onQuestionRepliedYes โœ…Yes โœ…Yes โœ…
onSurveyCompletedYes โœ…Yes โœ…Yes โœ…
onSurveyHiddenYes โœ…Yes โœ…Yes โœ…
onAppStoreRatingTriggeredYes โœ…Yes โœ…Yes โœ…
onReadyYes โœ…No โŒNo โŒ
onSurveyDisplayAllowedYes โœ…No โŒNo โŒ

Set hooks on SDK initโ€‹

PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onReady": (dynamic data) {
log("onReady $data");
},
"onSurveyDisplayAllowed": (dynamic data) {
log("onSurveyDisplayAllowed $data");
return true;
},
});

Set hooks on survey startโ€‹

PluginScreeb.startSurvey("<surveyId>", hooks: <String, dynamic>{
"version": "1.0.0",
"onSurveyShowed": (dynamic data) {
print("onSurveyShowed");
print(data.toString());
},
"onQuestionReplied": (dynamic data) {
print("onQuestionReplied");
print(data.toString());
},
});

Set hooks on message startโ€‹

PluginScreeb.startMessage("<messageId>", hooks: <String, dynamic>{
"version": "1.0.0",
"onSurveyShowed": (dynamic data) {
print("onSurveyShowed");
print(data.toString());
},
"onQuestionReplied": (dynamic data) {
print("onQuestionReplied");
print(data.toString());
},
});

onSurveyShowedโ€‹

Called when a survey is showed.

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onSurveyShowed": (dynamic data) {
log("onSurveyShowed $data");
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyStartedโ€‹

Called when a survey is started.

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onSurveyStarted": (dynamic data) {
log("onSurveyStarted $data");
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
},
user: {
anonymous_id: string,
user_id: string,
}
}

onQuestionRepliedโ€‹

Called when a question is replied.

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onQuestionReplied": (dynamic data) {
log("onQuestionReplied $data");
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
status: "started" | "ended" | "closed" | "interrupted"
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
};
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyCompletedโ€‹

Called when a survey is completed.

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onSurveyCompleted": (dynamic data) {
log("onSurveyCompleted $data");
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyHiddenโ€‹

Called when a survey is hidden.

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onSurveyHidden": (dynamic data) {
log("onSurveyHidden $data");
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
hide_reason: "started" | "ended" | "closed" | "interrupted",
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onAppStoreRatingTriggeredโ€‹

Called when an App Store Rating question is triggered.

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onAppStoreRatingTriggered": (dynamic data) {
log("onAppStoreRatingTriggered $data");
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
user: {
anonymous_id: string,
user_id: string,
}
}

onReadyโ€‹

Called when the SDK is ready. Only available on PluginScreeb.initSdk().

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onReady": (dynamic data) {
log("OnReady $data");
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyDisplayAllowedโ€‹

Called before a survey display to allow it or not. Only available on PluginScreeb.initSdk(). Return a boolean value. Return false to prevent display.

Example
PluginScreeb.initSdk(
"<channel-id>",
hooks: <String, dynamic>{
"version": "1.0.0",
"onSurveyDisplayAllowed": (dynamic data) {
log("onSurveyDisplayAllowed $data");
return true;
},
});
Payload definition
{
channel: {
id: string,
type: "ios"
},
survey: {
id: string,
},
user: {
anonymous_id: string,
user_id: string,
}
}