Skip to content

Commit 8d6abc8

Browse files
committed
Reset sessions' direct influences
When a session ends, reset the sessions' direct influences to prevent a direct session from being sent up twice for the same notification
1 parent 0c1d008 commit 8d6abc8

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

iOS_SDK/OneSignalSDK/OneSignalOutcomes/Source/OutcomeEvents/OSSessionManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
- (void)onNotificationReceived:(NSString * _Nonnull)notificationId;
5555
- (void)onDirectInfluenceFromNotificationOpen:(AppEntryAction)entryAction withNotificationId:(NSString * _Nonnull)directNotificationId;
5656
- (void)attemptSessionUpgrade:(AppEntryAction)entryAction;
57+
- (void)resetSessionIfDirect;
5758

5859
@end

iOS_SDK/OneSignalSDK/OneSignalOutcomes/Source/OutcomeEvents/OSSessionManager.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ - (void)initSessionFromCache {
7272
[OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:[NSString stringWithFormat:@"SessionManager restored from cache with influences: %@", [self getInfluences].description]];
7373
}
7474

75+
- (void)resetSessionIfDirect {
76+
[OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:@"OneSignal SessionManager resetSessionIfDirect"];
77+
NSArray<OSChannelTracker *> *channels = [_trackerFactory channels];
78+
for (OSChannelTracker *tracker in channels) {
79+
if (tracker.influenceType == DIRECT) {
80+
[tracker resetAndInitInfluence];
81+
}
82+
}
83+
}
84+
7585
- (void)restartSessionIfNeeded:(AppEntryAction)entryAction {
7686
NSArray<OSChannelTracker *> *channelTrackers = [_trackerFactory channelsToResetByEntryAction:entryAction];
7787
NSMutableArray<OSInfluence *> *updatedInfluences = [NSMutableArray new];

iOS_SDK/OneSignalSDK/Source/OSAttributedFocusTimeProcessor.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ - (void)sendBackgroundAttributedFocusPingWithParams:(OSFocusCallParams *)params
117117

118118
[OneSignal.stateSynchronizer sendOnFocusTime:totalTimeActive params:params withSuccess:^(NSDictionary *result) {
119119
[super saveUnsentActiveTime:0];
120+
if (params != nil) {
121+
[[OSSessionManager sharedSessionManager] resetSessionIfDirect];
122+
}
120123
[OneSignal onesignalLog:ONE_S_LL_DEBUG message:@"sendOnFocusCallWithParams attributed succeed, saveUnsentActiveTime with 0"];
121124
[self endDelayBackgroundTask];
122125
} onFailure:^(NSDictionary<NSString *, NSError *> *errors) {

0 commit comments

Comments
 (0)