@@ -25,6 +25,10 @@ typedef void EmailSubscriptionChangeHandler(OSEmailSubscriptionStateChanges chan
2525typedef void SMSSubscriptionChangeHandler (OSSMSSubscriptionStateChanges changes);
2626typedef void PermissionChangeHandler (OSPermissionStateChanges changes);
2727typedef 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);
2832typedef void NotificationWillShowInForegroundHandler (OSNotificationReceivedEvent event);
2933
3034class OneSignal {
@@ -47,6 +51,10 @@ class OneSignal {
4751 SMSSubscriptionChangeHandler ? _onSMSSubscriptionChangedHandler;
4852 PermissionChangeHandler ? _onPermissionChangedHandler;
4953 InAppMessageClickedHandler ? _onInAppMessageClickedHandler;
54+ OnWillDisplayInAppMessageHandler ? _onWillDisplayInAppMessageHandler;
55+ OnDidDisplayInAppMessageHandler ? _onDidDisplayInAppMessageHandler;
56+ OnWillDismissInAppMessageHandler ? _onWillDismissInAppMessageHandler;
57+ OnDidDismissInAppMessageHandler ? _onDidDismissInAppMessageHandler;
5058 NotificationWillShowInForegroundHandler ? _onNotificationWillShowInForegroundHandler;
5159
5260 // constructor method
@@ -114,6 +122,34 @@ class OneSignal {
114122 _channel.invokeMethod ("OneSignal#initInAppMessageClickedHandlerParams" );
115123 }
116124
125+ /// The in app message will display handler is called whenever the in app message
126+ /// is about to be displayed
127+ void setOnWillDisplayInAppMessageHandler (
128+ OnWillDisplayInAppMessageHandler handler) {
129+ _onWillDisplayInAppMessageHandler = handler;
130+ }
131+
132+ /// The in app message did display handler is called whenever the in app message
133+ /// is displayed
134+ void setOnDidDisplayInAppMessageHandler (
135+ OnDidDisplayInAppMessageHandler handler) {
136+ _onDidDisplayInAppMessageHandler = handler;
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 (
142+ OnWillDismissInAppMessageHandler handler) {
143+ _onWillDismissInAppMessageHandler = handler;
144+ }
145+
146+ /// The in app message did dismiss handler is called whenever the in app message
147+ /// is dismissed
148+ void setOnDidDismissInAppMessageHandler (
149+ OnDidDismissInAppMessageHandler handler) {
150+ _onDidDismissInAppMessageHandler = handler;
151+ }
152+
117153 /// The notification foreground handler is called whenever a notification arrives
118154 /// and the application is in foreground
119155 void setNotificationWillShowInForegroundHandler (NotificationWillShowInForegroundHandler handler) {
@@ -428,6 +464,22 @@ class OneSignal {
428464 this ._onInAppMessageClickedHandler != null ) {
429465 this ._onInAppMessageClickedHandler !(
430466 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 >()));
431483 } else if (call.method == 'OneSignal#handleNotificationWillShowInForeground' &&
432484 this ._onNotificationWillShowInForegroundHandler != null ) {
433485 this ._onNotificationWillShowInForegroundHandler !(
0 commit comments