@@ -25,6 +25,10 @@ typedef void EmailSubscriptionChangeHandler(OSEmailSubscriptionStateChanges chan
25
25
typedef void SMSSubscriptionChangeHandler (OSSMSSubscriptionStateChanges changes);
26
26
typedef void PermissionChangeHandler (OSPermissionStateChanges changes);
27
27
typedef void InAppMessageClickedHandler (OSInAppMessageAction action);
28
+ typedef void OnWillDisplayInAppMessageHandler (OSInAppMessage message);
29
+ typedef void OnDidDisplayInAppMessageHandler (OSInAppMessage message);
30
+ typedef void OnWillDismissInAppMessageHandler (OSInAppMessage message);
31
+ typedef void OnDidDismissInAppMessageHandler (OSInAppMessage message);
28
32
typedef void NotificationWillShowInForegroundHandler (OSNotificationReceivedEvent event);
29
33
30
34
class OneSignal {
@@ -47,6 +51,10 @@ class OneSignal {
47
51
SMSSubscriptionChangeHandler ? _onSMSSubscriptionChangedHandler;
48
52
PermissionChangeHandler ? _onPermissionChangedHandler;
49
53
InAppMessageClickedHandler ? _onInAppMessageClickedHandler;
54
+ OnWillDisplayInAppMessageHandler ? _onWillDisplayInAppMessageHandler;
55
+ OnDidDisplayInAppMessageHandler ? _onDidDisplayInAppMessageHandler;
56
+ OnWillDismissInAppMessageHandler ? _onWillDismissInAppMessageHandler;
57
+ OnDidDismissInAppMessageHandler ? _onDidDismissInAppMessageHandler;
50
58
NotificationWillShowInForegroundHandler ? _onNotificationWillShowInForegroundHandler;
51
59
52
60
// constructor method
@@ -114,6 +122,34 @@ class OneSignal {
114
122
_channel.invokeMethod ("OneSignal#initInAppMessageClickedHandlerParams" );
115
123
}
116
124
125
+ /// The in app message will display handler is called whenever the in app message
126
+ /// is about to be displayed
127
+ void setOnWillDisplayInAppMessageHandler (OnWillDisplayInAppMessageHandler handler) {
128
+ _onWillDisplayInAppMessageHandler = handler;
129
+ _channel.invokeMethod ("OneSignal#onWillDisplayInAppMessageHandlerParams" );
130
+ }
131
+
132
+ /// The in app message did display handler is called whenever the in app message
133
+ /// is displayed
134
+ void setOnDidDisplayInAppMessageHandler (OnDidDisplayInAppMessageHandler handler) {
135
+ _onDidDisplayInAppMessageHandler = handler;
136
+ _channel.invokeMethod ("OneSignal#onDidDisplayInAppMessageHandlerParams" );
137
+ }
138
+
139
+ /// The in app message will dismiss handler is called whenever the in app message
140
+ /// is about to be dismissed
141
+ void setOnWillDismissInAppMessageHandler (OnWillDismissInAppMessageHandler handler) {
142
+ _onWillDismissInAppMessageHandler = handler;
143
+ _channel.invokeMethod ("OneSignal#onWillDismissInAppMessageHandlerParams" );
144
+ }
145
+
146
+ /// The in app message did dismiss handler is called whenever the in app message
147
+ /// is dismissed
148
+ void setOnDidDismissInAppMessageHandler (OnDidDismissInAppMessageHandler handler) {
149
+ _onDidDismissInAppMessageHandler = handler;
150
+ _channel.invokeMethod ("OneSignal#onDidDismissInAppMessageHandlerParams" );
151
+ }
152
+
117
153
/// The notification foreground handler is called whenever a notification arrives
118
154
/// and the application is in foreground
119
155
void setNotificationWillShowInForegroundHandler (NotificationWillShowInForegroundHandler handler) {
@@ -428,6 +464,22 @@ class OneSignal {
428
464
this ._onInAppMessageClickedHandler != null ) {
429
465
this ._onInAppMessageClickedHandler !(
430
466
OSInAppMessageAction (call.arguments.cast <String , dynamic >()));
467
+ } else if (call.method == 'OneSignal#onWillDisplayInAppMessage' &&
468
+ this ._onWillDisplayInAppMessageHandler != null ) {
469
+ this ._onWillDisplayInAppMessageHandler !(
470
+ OSInAppMessage (call.arguments.cast <String , dynamic >()));
471
+ } else if (call.method == 'OneSignal#onDidDisplayInAppMessage' &&
472
+ this ._onDidDisplayInAppMessageHandler != null ) {
473
+ this ._onDidDisplayInAppMessageHandler !(
474
+ OSInAppMessage (call.arguments.cast <String , dynamic >()));
475
+ } else if (call.method == 'OneSignal#onWillDismissInAppMessage' &&
476
+ this ._onWillDismissInAppMessageHandler != null ) {
477
+ this ._onWillDismissInAppMessageHandler !(
478
+ OSInAppMessage (call.arguments.cast <String , dynamic >()));
479
+ } else if (call.method == 'OneSignal#onDidDismissInAppMessage' &&
480
+ this ._onDidDismissInAppMessageHandler != null ) {
481
+ this ._onDidDismissInAppMessageHandler !(
482
+ OSInAppMessage (call.arguments.cast <String , dynamic >()));
431
483
} else if (call.method == 'OneSignal#handleNotificationWillShowInForeground' &&
432
484
this ._onNotificationWillShowInForegroundHandler != null ) {
433
485
this ._onNotificationWillShowInForegroundHandler !(
0 commit comments