Skip to main content
Version: .NET MAUI 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 InitSdk(), StartSurvey(), and StartMessage() commands. Hooks are all optional.

Available hooksโ€‹

Hook NameAvailable on InitSdk()Available on StartSurvey()Available on StartMessage()
onSurveyShowedYes โœ…Yes โœ…Yes โœ…
onMessageShowedYes โœ…Yes โœ…Yes โœ…
onSurveyStartedYes โœ…Yes โœ…Yes โœ…
onMessageStartedYes โœ…Yes โœ…Yes โœ…
onQuestionRepliedYes โœ…Yes โœ…Yes โœ…
onSurveyCompletedYes โœ…Yes โœ…Yes โœ…
onMessageCompletedYes โœ…Yes โœ…Yes โœ…
onSurveyHiddenYes โœ…Yes โœ…Yes โœ…
onMessageHiddenYes โœ…Yes โœ…Yes โœ…
onAppStoreRatingTriggeredYes โœ…Yes โœ…Yes โœ…
onReadyYes โœ…No โŒNo โŒ
onSurveyDisplayAllowedYes โœ…No โŒNo โŒ
onMessageDisplayAllowedYes โœ…No โŒNo โŒ

Set hooks on SDK initโ€‹

var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onReady"] = async (payload) =>
{
Console.WriteLine($"onReady: {payload}");
return null;
},
["onSurveyDisplayAllowed"] = async (payload) =>
{
Console.WriteLine($"onSurveyDisplayAllowed: {payload}");
// return false to prevent display
return true;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
properties: new Dictionary<string, object>
{
["isConnected"] = false,
["age"] = 29,
["product"] = "iPhone 13",
["email"] = "support@screeb.app"
},
hooks: hooks
);

Set hooks on survey startโ€‹

var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onSurveyShowed"] = async (payload) =>
{
Console.WriteLine($"onSurveyShowed: {payload}");
return null;
}
}
};

await Screeb.StartSurvey(
surveyId: "<survey-id>",
allowMultipleResponses: true,
hiddenFields: new Dictionary<string, object>(),
ignoreSurveyStatus: true,
hooks: hooks
);

Set hooks on message startโ€‹

var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onMessageShowed"] = async (payload) =>
{
Console.WriteLine($"onMessageShowed: {payload}");
return null;
}
}
};

await Screeb.StartMessage(
messageId: "<message-id>",
allowMultipleResponses: true,
hiddenFields: new Dictionary<string, object>(),
ignoreMessageStatus: true,
hooks: hooks
);

onSurveyShowedโ€‹

Called when a survey is showed.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onSurveyShowed"] = async (payload) =>
{
Console.WriteLine($"onSurveyShowed: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);
Payload definition
{
channel: {
id: string,
type: "android" | "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
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onSurveyStarted"] = async (payload) =>
{
Console.WriteLine($"onSurveyStarted: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);
Payload definition
{
channel: {
id: string,
type: "android" | "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
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onQuestionReplied"] = async (payload) =>
{
Console.WriteLine($"onQuestionReplied: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onSurveyCompletedโ€‹

Called when a survey is completed.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onSurveyCompleted"] = async (payload) =>
{
Console.WriteLine($"onSurveyCompleted: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onSurveyHiddenโ€‹

Called when a survey is hidden.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onSurveyHidden"] = async (payload) =>
{
Console.WriteLine($"onSurveyHidden: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onMessageShowedโ€‹

Called when a message is showed.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onMessageShowed"] = async (payload) =>
{
Console.WriteLine($"onMessageShowed: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onMessageStartedโ€‹

Called when a message is started.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onMessageStarted"] = async (payload) =>
{
Console.WriteLine($"onMessageStarted: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onMessageCompletedโ€‹

Called when a message is completed.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onMessageCompleted"] = async (payload) =>
{
Console.WriteLine($"onMessageCompleted: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onMessageHiddenโ€‹

Called when a message is hidden.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onMessageHidden"] = async (payload) =>
{
Console.WriteLine($"onMessageHidden: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onAppStoreRatingTriggeredโ€‹

Called when app store rating is triggered.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onAppStoreRatingTriggered"] = async (payload) =>
{
Console.WriteLine($"onAppStoreRatingTriggered: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onReadyโ€‹

Called when the SDK is ready.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onReady"] = async (payload) =>
{
Console.WriteLine($"onReady: {payload}");
return null;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onSurveyDisplayAllowedโ€‹

Called before a survey is about to be displayed. Return false to prevent the display.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onSurveyDisplayAllowed"] = async (payload) =>
{
Console.WriteLine($"onSurveyDisplayAllowed: {payload}");
// Return false to prevent display
return true;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);

onMessageDisplayAllowedโ€‹

Called before a message is about to be displayed. Return false to prevent the display.

Example
var hooks = new ScreebHooks
{
Version = "1.0.0",
Callbacks = new Dictionary<string, Func<string, Task<object?>>>
{
["onMessageDisplayAllowed"] = async (payload) =>
{
Console.WriteLine($"onMessageDisplayAllowed: {payload}");
// Return false to prevent display
return true;
}
}
};

await Screeb.InitSdk(
channelId: "<YOUR-CHANNEL-ID>",
userId: "<USER-ID>",
hooks: hooks
);