@@ -57,25 +57,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5757
5858 _notificationDelegate = [OneSignalNotificationCenterDelegate new ];
5959
60- id openNotificationHandler = ^(OSNotificationOpenedResult *result) {
61- // TODO: opened handler Not triggered
62- NSLog (@" OSNotificationOpenedResult: %@ " , result.action );
63- #pragma clang diagnostic push
64- #pragma clang diagnostic ignored "-Wdeprecated"
65- UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Notifiation Opened In App Delegate" message: @" Notification Opened In App Delegate" delegate: self cancelButtonTitle: @" Delete" otherButtonTitles: @" Cancel" , nil ];
66- [alert show ];
67- #pragma clang diagnostic pop
68- };
69-
70- // Example block for IAM action click handler
71- id inAppMessagingActionClickBlock = ^(OSInAppMessageAction *action) {
72- NSString *message = [NSString stringWithFormat: @" Click Action Occurred: %@ " , [action jsonRepresentation ]];
73- [OneSignalLog onesignalLog: ONE_S_LL_DEBUG message: message];
74- };
75-
76- // Example setter for IAM action click handler using OneSignal public method
77- [OneSignal.InAppMessages setClickHandler: inAppMessagingActionClickBlock];
78-
7960 // OneSignal Init with app id and lauch options
8061 [OneSignal setLaunchURLsInApp: YES ];
8162 [OneSignal setProvidesNotificationSettingsView: NO ];
@@ -84,13 +65,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
8465 [OneSignal.InAppMessages paused: true ];
8566
8667 [OneSignal.Notifications addForegroundLifecycleListener: self ];
87- [OneSignal.Notifications setNotificationOpenedHandler: openNotificationHandler];
88-
68+ [OneSignal.Notifications addClickListener: self ];
8969 [OneSignal.User.pushSubscription addObserver: self ];
9070 NSLog (@" OneSignal Demo App push subscription observer added" );
9171
9272 [OneSignal.Notifications addPermissionObserver: self ];
93-
73+ [OneSignal.InAppMessages addClickListener: self ];
74+
9475 NSLog (@" UNUserNotificationCenter.delegate: %@ " , UNUserNotificationCenter .currentNotificationCenter .delegate );
9576
9677 return YES ;
@@ -117,17 +98,20 @@ - (void)onNotificationPermissionDidChange:(BOOL)permission {
11798 NSLog (@" Dev App onNotificationPermissionDidChange: %d " , permission);
11899}
119100
120- - (void )onOSPushSubscriptionChangedWithStateChanges : (OSPushSubscriptionStateChanges *)stateChanges {
121- NSLog (@" Dev App onOSPushSubscriptionChangedWithStateChanges : %@ " , stateChanges );
101+ - (void )onPushSubscriptionDidChangeWithState : (OSPushSubscriptionChangedState *)state {
102+ NSLog (@" Dev App onPushSubscriptionDidChange : %@ " , state );
122103 ViewController* mainController = (ViewController*) self.window .rootViewController ;
123- mainController.subscriptionSegmentedControl .selectedSegmentIndex = (NSInteger ) stateChanges.to .optedIn ;
104+ mainController.subscriptionSegmentedControl .selectedSegmentIndex = (NSInteger ) state.current .optedIn ;
105+ }
106+
107+ - (void )onClickNotification : (OSNotificationClickEvent * _Nonnull)event {
108+ NSLog (@" Dev App onClickNotification with event %@ " , [event jsonRepresentation ]);
124109}
125110
126111#pragma mark OSInAppMessageDelegate
127112
128- - (void )handleMessageAction : (OSInAppMessageAction *)action {
129- NSLog (@" OSInAppMessageDelegate: handling message action: %@ " ,action);
130- return ;
113+ - (void )onClickInAppMessage : (OSInAppMessageClickEvent * _Nonnull)event {
114+ NSLog (@" Dev App onClickInAppMessage event: %@ " , [event jsonRepresentation ]);
131115}
132116
133117- (void )onWillDisplayNotification : (OSNotificationWillDisplayEvent *)event {
@@ -139,22 +123,22 @@ - (void)onWillDisplayNotification:(OSNotificationWillDisplayEvent *)event {
139123}
140124
141125- (void )onWillDisplayInAppMessage : (OSInAppMessageWillDisplayEvent *)event {
142- NSLog (@" OSInAppMessageDelegate : onWillDisplay Message: %@ " ,event.message );
126+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onWillDisplay Message: %@ " ,event.message );
143127 return ;
144128}
145129
146130- (void )onDidDisplayInAppMessage : (OSInAppMessageDidDisplayEvent *)event {
147- NSLog (@" OSInAppMessageDelegate : onDidDisplay Message: %@ " ,event.message );
131+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onDidDisplay Message: %@ " ,event.message );
148132 return ;
149133}
150134
151135- (void )onWillDismissInAppMessage : (OSInAppMessageWillDismissEvent *)event {
152- NSLog (@" OSInAppMessageDelegate : onWillDismiss Message: %@ " ,event.message );
136+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onWillDismiss Message: %@ " ,event.message );
153137 return ;
154138}
155139
156140- (void )onDidDismissInAppMessage : (OSInAppMessageDidDismissEvent *)event {
157- NSLog (@" OSInAppMessageDelegate : onDidDismiss Message: %@ " ,event.message );
141+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onDidDismiss Message: %@ " ,event.message );
158142 return ;
159143}
160144
0 commit comments