In-App Message Event Listener
Interfaces
HackleInAppMessageListener
interface HackleInAppMessageListener {
beforeInAppMessageOpen?(inAppMessage: HackleInAppMessage): void;
afterInAppMessageOpen?(inAppMessage: HackleInAppMessage): void;
beforeInAppMessageClose?(inAppMessage: HackleInAppMessage): void;
afterInAppMessageClose?(inAppMessage: HackleInAppMessage): void;
onInAppMessageClick?(
inAppMessage: HackleInAppMessage,
view: HackleInAppMessageView,
action: HackleInAppMessageAction
): boolean;
}onInAppMessageClick
You can control the behavior of the in-app message through the boolean value returned by the onInAppMessageClick method.
Returning
trueoverrides the original action of the in-app message.For example, if the original click action was
Do not show for a day, that action will not execute.
Returning
falseallows the original action of the in-app message to proceed.
Calling view.close() inside onInAppMessageClick
Calling view.close() inside the listener is treated the same as returning true.
HackleInAppMessage
Returns the key of the in-app message.
HackleInAppMessageView
You can close the in-app message directly within the listener function by calling
close().
HackleInAppMessageAction
close?.hideDurationMillis
If the action hides the message for a specific period, returns that duration in milliseconds.
link?.url
Returns the link if one is included. e.g) https://hackle.io
link?.shouldCloseAfterLink
Returns true if the close-after-link option is ON.
Usage Example
Registering a Listener
Removing a Listener
Pass
nulltosetInAppMessageListener()to remove the registered listener.
Last updated