-
Notifications
You must be signed in to change notification settings - Fork 7
/
IInAppMessageManagerListener.kt
127 lines (116 loc) · 5.56 KB
/
IInAppMessageManagerListener.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@file:Suppress("DEPRECATION")
package com.braze.ui.inappmessage.listeners
import android.view.View
import com.braze.models.inappmessage.IInAppMessage
import com.braze.models.inappmessage.MessageButton
import com.braze.support.BrazeFunctionNotImplemented
import com.braze.ui.inappmessage.InAppMessageCloser
import com.braze.ui.inappmessage.InAppMessageOperation
/**
* The IInAppMessageManagerListener returns the in-app message at specific
* events in its control flow and gives the host app the option of
* overriding Braze's default display handling and implementing its own custom behavior.
*
*
* If you are implementing Unity, you must use IBrazeUnityInAppMessageListener instead.
*
*
* See [BrazeInAppMessageManager]
*/
interface IInAppMessageManagerListener {
/**
* @param inAppMessage The in-app message that is currently requested for display.
* @return InAppMessageOperation indicating how to handle the candidate in-app message.
*/
fun beforeInAppMessageDisplayed(inAppMessage: IInAppMessage): InAppMessageOperation = InAppMessageOperation.DISPLAY_NOW
/**
* @param inAppMessage The clicked in-app message.
* @param inAppMessageCloser Closing should not be animated if transitioning to a new activity.
* If remaining in the same activity, closing should be animated.
* @return boolean flag to indicate to Braze whether the click has been manually handled.
* If true, Braze will only log a click and do nothing else. If false, Braze will
* log a click and also close the in-app message automatically.
*/
@Deprecated("InAppMessageCloser is deprecated", ReplaceWith("onInAppMessageClicked(inAppMessage)"))
fun onInAppMessageClicked(inAppMessage: IInAppMessage, inAppMessageCloser: InAppMessageCloser?): Boolean = throw BrazeFunctionNotImplemented
/**
* @param inAppMessage The clicked in-app message.
* @return boolean flag to indicate to Braze whether the click has been manually handled.
* If true, Braze will only log a click and do nothing else. If false, Braze will
* log a click and also close the in-app message automatically.
*/
fun onInAppMessageClicked(inAppMessage: IInAppMessage) = false
/**
* @param inAppMessage The clicked in-app message.
* @param button The clicked message button.
* @param inAppMessageCloser Closing should not be animated if transitioning to a new activity.
* If remaining in the same activity, closing should be animated.
* @return boolean flag to indicate to Braze whether the click has been manually handled.
* If true, Braze will only log a click and do nothing else. If false, Braze will
* log a click and also close the in-app message automatically.
*/
@Deprecated("InAppMessageCloser is deprecated", ReplaceWith("onInAppMessageButtonClicked(inAppMessage, button)"))
fun onInAppMessageButtonClicked(
inAppMessage: IInAppMessage,
button: MessageButton,
inAppMessageCloser: InAppMessageCloser?
): Boolean = throw BrazeFunctionNotImplemented
/**
* @param inAppMessage The clicked in-app message.
* @param button The clicked message button.
* @return boolean flag to indicate to Braze whether the click has been manually handled.
* If true, Braze will only log a click and do nothing else. If false, Braze will
* log a click and also close the in-app message automatically.
*/
fun onInAppMessageButtonClicked(inAppMessage: IInAppMessage, button: MessageButton) = false
/**
* @param inAppMessage the in-app message that was closed.
*/
fun onInAppMessageDismissed(inAppMessage: IInAppMessage) {}
/**
* Called before the in-app message View is added to the layout.
*
*
* Note that this is called before any default processing in
* [DefaultInAppMessageViewLifecycleListener] takes place.
*
* @param inAppMessageView The [View] representing the [IInAppMessage].
* @param inAppMessage The [IInAppMessage] being displayed.
*/
fun beforeInAppMessageViewOpened(inAppMessageView: View, inAppMessage: IInAppMessage) {}
/**
* Called after the in-app message View has been added to the layout
* (and the appearing animation has completed).
*
*
* Note that this is called after any default processing in
* [DefaultInAppMessageViewLifecycleListener] takes place.
*
* @param inAppMessageView The [View] representing the [IInAppMessage].
* @param inAppMessage The [IInAppMessage] being displayed.
*/
fun afterInAppMessageViewOpened(inAppMessageView: View, inAppMessage: IInAppMessage) {}
/**
* Called before the in-app message View is removed from the layout
* (and before any closing animation starts).
*
*
* Note that this is called before any default processing in
* [DefaultInAppMessageViewLifecycleListener] takes place.
*
* @param inAppMessageView The [View] representing the [IInAppMessage].
* @param inAppMessage The [IInAppMessage] being displayed.
*/
fun beforeInAppMessageViewClosed(inAppMessageView: View, inAppMessage: IInAppMessage) {}
/**
* Called after the in-app message View has been removed from the
* layout (and the disappearing animation has completed).
*
*
* Note that this is called after any default processing in
* [DefaultInAppMessageViewLifecycleListener] takes place.
*
* @param inAppMessage The [IInAppMessage] being displayed.
*/
fun afterInAppMessageViewClosed(inAppMessage: IInAppMessage) {}
}