Skip to content

Commit 9d27761

Browse files
committed
[nit] display event does not need preventDefault state
* It can just use the `wantsToDisplay` property of the notification it owns.
1 parent 2cc2c36 commit 9d27761

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotification+OneSignal.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ - (void)complete:(OSDisplayableNotification *)notification {
8585
}
8686
}
8787

88+
- (BOOL)wantsToDisplay {
89+
return _wantsToDisplay;
90+
}
91+
8892
- (void)setWantsToDisplay:(BOOL)display {
8993
_wantsToDisplay = display;
9094
}

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ @interface OSDisplayableNotification ()
9393
- (void)startTimeoutTimer;
9494
- (void)setCompletionBlock:(OSNotificationDisplayResponse)completion;
9595
- (void)complete:(OSDisplayableNotification *)notification;
96+
- (BOOL)wantsToDisplay;
9697
- (void)setWantsToDisplay:(BOOL)display;
9798
@end
9899

99100
@implementation OSNotificationWillDisplayEvent
100101

101-
BOOL _isPreventDefault = false;
102-
103102
- (id)initWithDisplayableNotification:(OSDisplayableNotification*)notification {
104103
self = [super init];
105104
if(self) {
@@ -109,12 +108,11 @@ - (id)initWithDisplayableNotification:(OSDisplayableNotification*)notification {
109108
}
110109

111110
- (BOOL)isPreventDefault {
112-
return _isPreventDefault;
111+
return !_notification.wantsToDisplay;
113112
}
114113

115114
- (void)preventDefault {
116115
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"OSNotificationWillDisplayEvent.preventDefault called."]];
117-
_isPreventDefault = true;
118116
_notification.wantsToDisplay = false;
119117
}
120118

0 commit comments

Comments
 (0)