@@ -57,44 +57,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
57
57
58
58
_notificationDelegate = [OneSignalNotificationCenterDelegate new ];
59
59
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
- id notificationReceiverBlock = ^(OSNotification *notif, OSNotificationDisplayResponse completion) {
70
- NSLog (@" Will Receive Notification - %@ " , notif.notificationId );
71
- completion (notif);
72
- };
73
-
74
- // Example block for IAM action click handler
75
- id inAppMessagingActionClickBlock = ^(OSInAppMessageAction *action) {
76
- NSString *message = [NSString stringWithFormat: @" Click Action Occurred: %@ " , [action jsonRepresentation ]];
77
- [OneSignalLog onesignalLog: ONE_S_LL_DEBUG message: message];
78
- };
79
-
80
- // Example setter for IAM action click handler using OneSignal public method
81
- [OneSignal.InAppMessages setClickHandler: inAppMessagingActionClickBlock];
82
-
83
60
// OneSignal Init with app id and lauch options
84
61
[OneSignal setLaunchURLsInApp: YES ];
85
62
[OneSignal setProvidesNotificationSettingsView: NO ];
86
63
87
- [OneSignal.InAppMessages setLifecycleHandler :self ];
64
+ [OneSignal.InAppMessages addLifecycleListener :self ];
88
65
[OneSignal.InAppMessages paused: true ];
89
66
90
- [OneSignal.Notifications setNotificationWillShowInForegroundHandler: notificationReceiverBlock];
91
- [OneSignal.Notifications setNotificationOpenedHandler: openNotificationHandler];
92
-
67
+ [OneSignal.Notifications addForegroundLifecycleListener: self ];
68
+ [OneSignal.Notifications addClickListener: self ];
93
69
[OneSignal.User.pushSubscription addObserver: self ];
94
70
NSLog (@" OneSignal Demo App push subscription observer added" );
95
71
96
72
[OneSignal.Notifications addPermissionObserver: self ];
97
-
73
+ [OneSignal.InAppMessages addClickListener: self ];
74
+
98
75
NSLog (@" UNUserNotificationCenter.delegate: %@ " , UNUserNotificationCenter .currentNotificationCenter .delegate );
99
76
100
77
return YES ;
@@ -117,40 +94,51 @@ + (void) setOneSignalAppId:(NSString*)onesignalAppId {
117
94
// [OneSignal setAppId:onesignalAppId];
118
95
}
119
96
120
- - (void )onOSPermissionChanged : (OSPermissionState*) state {
121
- NSLog (@" Dev App onOSPermissionChanged : %@ " , state );
97
+ - (void )onNotificationPermissionDidChange : ( BOOL ) permission {
98
+ NSLog (@" Dev App onNotificationPermissionDidChange : %d " , permission );
122
99
}
123
100
124
- - (void )onOSPushSubscriptionChangedWithStateChanges : (OSPushSubscriptionStateChanges *)stateChanges {
125
- NSLog (@" Dev App onOSPushSubscriptionChangedWithStateChanges : %@ " , stateChanges );
101
+ - (void )onPushSubscriptionDidChangeWithState : (OSPushSubscriptionChangedState *)state {
102
+ NSLog (@" Dev App onPushSubscriptionDidChange : %@ " , state );
126
103
ViewController* mainController = (ViewController*) self.window .rootViewController ;
127
- 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 ]);
128
109
}
129
110
130
111
#pragma mark OSInAppMessageDelegate
131
112
132
- - (void )handleMessageAction : (OSInAppMessageAction *)action {
133
- NSLog (@" OSInAppMessageDelegate: handling message action: %@ " ,action);
134
- return ;
113
+ - (void )onClickInAppMessage : (OSInAppMessageClickEvent * _Nonnull)event {
114
+ NSLog (@" Dev App onClickInAppMessage event: %@ " , [event jsonRepresentation ]);
115
+ }
116
+
117
+ - (void )onWillDisplayNotification : (OSNotificationWillDisplayEvent *)event {
118
+ NSLog (@" Dev App OSNotificationWillDisplayEvent with event: %@ " ,event);
119
+ [event preventDefault ];
120
+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue (), ^{
121
+ [event.notification display ];
122
+ });
135
123
}
136
124
137
- - (void )onWillDisplayInAppMessage : (OSInAppMessage *)message {
138
- NSLog (@" OSInAppMessageDelegate : onWillDisplay Message: %@ " ,message);
125
+ - (void )onWillDisplayInAppMessage : (OSInAppMessageWillDisplayEvent *)event {
126
+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onWillDisplay Message: %@ " ,event. message );
139
127
return ;
140
128
}
141
129
142
- - (void )onDidDisplayInAppMessage : (OSInAppMessage *)message {
143
- NSLog (@" OSInAppMessageDelegate : onDidDisplay Message: %@ " ,message);
130
+ - (void )onDidDisplayInAppMessage : (OSInAppMessageDidDisplayEvent *)event {
131
+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onDidDisplay Message: %@ " ,event. message );
144
132
return ;
145
133
}
146
134
147
- - (void )onWillDismissInAppMessage : (OSInAppMessage *)message {
148
- NSLog (@" OSInAppMessageDelegate : onWillDismiss Message: %@ " ,message);
135
+ - (void )onWillDismissInAppMessage : (OSInAppMessageWillDismissEvent *)event {
136
+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onWillDismiss Message: %@ " ,event. message );
149
137
return ;
150
138
}
151
139
152
- - (void )onDidDismissInAppMessage : (OSInAppMessage *)message {
153
- NSLog (@" OSInAppMessageDelegate : onDidDismiss Message: %@ " ,message);
140
+ - (void )onDidDismissInAppMessage : (OSInAppMessageDidDismissEvent *)event {
141
+ NSLog (@" Dev App OSInAppMessageLifecycleListener : onDidDismiss Message: %@ " ,event. message );
154
142
return ;
155
143
}
156
144
0 commit comments