Skip to content

Commit 04c5dbe

Browse files
committed
Add Migration Logic
* For Encodable/Decodable objects * Migrate renamed objects that are saved on UserDefaults * Save last known version after migration
1 parent 989f71c commit 04c5dbe

File tree

10 files changed

+273
-21
lines changed

10 files changed

+273
-21
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
7A12EBDD23060B37005C4FA5 /* OSIndirectInfluence.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A12EBDC23060B37005C4FA5 /* OSIndirectInfluence.m */; };
7878
7A1F2D8F2406EFC5007799A9 /* OSInAppMessageTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A1F2D8E2406EFC5007799A9 /* OSInAppMessageTag.m */; };
7979
7A2E90622460DA1500B3428C /* OutcomeIntegrationV2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A2E90612460DA1500B3428C /* OutcomeIntegrationV2Tests.m */; };
80+
7A5A818224897693002E07C8 /* MigrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A5A818124897693002E07C8 /* MigrationTests.m */; };
81+
7A5A8185248990CD002E07C8 /* OSIndirectNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A5A8184248990CD002E07C8 /* OSIndirectNotification.m */; };
8082
7A600B42245378ED00514A53 /* OSFocusInfluenceParam.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A600B41245378ED00514A53 /* OSFocusInfluenceParam.h */; };
8183
7A600B442453790700514A53 /* OSFocusInfluenceParam.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A600B432453790700514A53 /* OSFocusInfluenceParam.m */; };
8284
7A600B452453790700514A53 /* OSFocusInfluenceParam.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A600B432453790700514A53 /* OSFocusInfluenceParam.m */; };
@@ -477,6 +479,9 @@
477479
7A1F2D8E2406EFC5007799A9 /* OSInAppMessageTag.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSInAppMessageTag.m; sourceTree = "<group>"; };
478480
7A1F2D902406EFDA007799A9 /* OSInAppMessageTag.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSInAppMessageTag.h; sourceTree = "<group>"; };
479481
7A2E90612460DA1500B3428C /* OutcomeIntegrationV2Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OutcomeIntegrationV2Tests.m; sourceTree = "<group>"; };
482+
7A5A818124897693002E07C8 /* MigrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MigrationTests.m; sourceTree = "<group>"; };
483+
7A5A8184248990CD002E07C8 /* OSIndirectNotification.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSIndirectNotification.m; sourceTree = "<group>"; };
484+
7A5A8186248990DA002E07C8 /* OSIndirectNotification.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSIndirectNotification.h; sourceTree = "<group>"; };
480485
7A600B41245378ED00514A53 /* OSFocusInfluenceParam.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSFocusInfluenceParam.h; sourceTree = "<group>"; };
481486
7A600B432453790700514A53 /* OSFocusInfluenceParam.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSFocusInfluenceParam.m; sourceTree = "<group>"; };
482487
7A65D628246627AD007FF196 /* OSInAppMessageViewOverrider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSInAppMessageViewOverrider.h; sourceTree = "<group>"; };
@@ -821,6 +826,15 @@
821826
name = Model;
822827
sourceTree = "<group>";
823828
};
829+
7A5A818324899050002E07C8 /* Models */ = {
830+
isa = PBXGroup;
831+
children = (
832+
7A5A8186248990DA002E07C8 /* OSIndirectNotification.h */,
833+
7A5A8184248990CD002E07C8 /* OSIndirectNotification.m */,
834+
);
835+
path = Models;
836+
sourceTree = "<group>";
837+
};
824838
7A674F172360D7DB001F9ACD /* OnFocus */ = {
825839
isa = PBXGroup;
826840
children = (
@@ -848,13 +862,13 @@
848862
name = ReceiveReceipts;
849863
sourceTree = "<group>";
850864
};
851-
7AAA606B2485D0D70004FADE /* migration */ = {
865+
7AAA606B2485D0D70004FADE /* Migration */ = {
852866
isa = PBXGroup;
853867
children = (
854868
7AAA60652485D0090004FADE /* OSMigrationController.h */,
855869
7AAA60672485D0420004FADE /* OSMigrationController.m */,
856870
);
857-
name = migration;
871+
name = Migration;
858872
sourceTree = "<group>";
859873
};
860874
7ABAF9D42457D3160074DFA0 /* Model */ = {
@@ -939,6 +953,7 @@
939953
911E2CBB1E398AB3003112A4 /* UnitTests */ = {
940954
isa = PBXGroup;
941955
children = (
956+
7A5A818324899050002E07C8 /* Models */,
942957
03866CBE2378A5ED0009C1D8 /* Asserts */,
943958
4529DECD1FA81DE000CEAB1D /* Shadows */,
944959
CA8E19012193C6B0009DA223 /* InAppMessagingIntegrationTests.m */,
@@ -969,14 +984,15 @@
969984
03217238238278EB004F0E85 /* DelayedSelectors.m */,
970985
7ABAF9D52457D3FF0074DFA0 /* ChannelTrackersTests.m */,
971986
7ABAF9D72457DD620074DFA0 /* SessionManagerTests.m */,
987+
7A5A818124897693002E07C8 /* MigrationTests.m */,
972988
);
973989
path = UnitTests;
974990
sourceTree = "<group>";
975991
};
976992
912411EE1E73342200E41FD7 /* Source */ = {
977993
isa = PBXGroup;
978994
children = (
979-
7AAA606B2485D0D70004FADE /* migration */,
995+
7AAA606B2485D0D70004FADE /* Migration */,
980996
7AF98632243F84AC00C36EAE /* Influence */,
981997
7A674F172360D7DB001F9ACD /* OnFocus */,
982998
7ADE379222E8B56F00263048 /* OutcomeEvents */,
@@ -1652,6 +1668,7 @@
16521668
03217239238278EB004F0E85 /* DelayedSelectors.m in Sources */,
16531669
CA63AF8720211FF800E340FB /* UnitTestCommonMethods.m in Sources */,
16541670
CA70E3372023D51300019273 /* OneSignalSetEmailParameters.m in Sources */,
1671+
7A5A8185248990CD002E07C8 /* OSIndirectNotification.m in Sources */,
16551672
4529DED81FA8253D00CEAB1D /* NSUserDefaultsOverrider.m in Sources */,
16561673
4529DEED1FA83C5D00CEAB1D /* OneSignalHelperOverrider.m in Sources */,
16571674
7AF98666244975AD00C36EAE /* OSOutcomeSourceBody.m in Sources */,
@@ -1728,6 +1745,7 @@
17281745
4529DEEA1FA8360C00CEAB1D /* UIApplicationOverrider.m in Sources */,
17291746
912412281E73342200E41FD7 /* OneSignalMobileProvision.m in Sources */,
17301747
7AECE59823674AB700537907 /* OSUnattributedFocusTimeProcessor.m in Sources */,
1748+
7A5A818224897693002E07C8 /* MigrationTests.m in Sources */,
17311749
7AECE5A023675F6300537907 /* OSFocusTimeProcessorFactory.m in Sources */,
17321750
9129C6C01E89E7AB009CB6A0 /* OSSubscription.m in Sources */,
17331751
912412141E73342200E41FD7 /* OneSignalAlertViewDelegate.m in Sources */,

iOS_SDK/OneSignalSDK/Source/OSChannelTracker.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ - (id)initWithRepository:(OSInfluenceDataRepository *)dataRepository {
5151
*/
5252
- (NSString * _Nonnull)idTag { mustOverride(); }
5353
- (OSInfluenceChannel)channelType { mustOverride(); }
54-
- (NSArray * _Nonnull)lastChannelObjectsReceivedByNewId:(NSString *)identifier { mustOverride(); }
55-
- (NSArray * _Nonnull)lastChannelObjects { mustOverride(); }
54+
- (NSArray * _Nullable)lastChannelObjectsReceivedByNewId:(NSString *)identifier { mustOverride(); }
55+
- (NSArray * _Nullable)lastChannelObjects { mustOverride(); }
5656
- (NSInteger)channelLimit { mustOverride(); }
5757
- (NSInteger)indirectAttributionWindow { mustOverride(); }
5858
- (void)saveChannelObjects:(NSArray * _Nonnull)channelObjects { mustOverride(); }
@@ -116,7 +116,7 @@ - (void)saveLastId:(NSString *)lastId {
116116

117117
// Create channelObjectToSave to be saved at a limited size, removing any old notifications
118118
NSArray *channelObjectToSave;
119-
if (lastChannelObjectsReceived == nil || lastChannelObjectsReceived.count == 0) {
119+
if (!lastChannelObjectsReceived || lastChannelObjectsReceived.count == 0) {
120120
channelObjectToSave = [NSArray arrayWithObject:indirectInfluence];
121121
} else if (lastChannelObjectsReceived.count < channelLimit) {
122122
NSMutableArray *lastChannelObjectsReceivedMutable = [lastChannelObjectsReceived mutableCopy];

iOS_SDK/OneSignalSDK/Source/OSInAppMessageTracker.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ - (NSArray * _Nonnull)lastChannelObjectsReceivedByNewId:(NSString *)identifier {
6161
return auxLastChannelObjectReceived;
6262
}
6363

64-
- (NSArray * _Nonnull)lastChannelObjects {
64+
- (NSArray * _Nullable)lastChannelObjects {
6565
return [self.dataRepository lastIAMsReceivedData];
6666
}
6767

iOS_SDK/OneSignalSDK/Source/OSInfluenceDataRepository.m

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ - (NSString *)cachedNotificationOpenId {
6060
}
6161

6262
- (void)cacheIndirectNotifications:(NSArray *)notifications {
63-
[OneSignalUserDefaults.initShared saveCodeableDataForKey:OSUD_CACHED_INDIRECT_NOTIFICATION_IDS withValue:notifications];
63+
[OneSignalUserDefaults.initShared saveObjectForKey:OSUD_CACHED_INDIRECT_NOTIFICATION_IDS withValue:notifications];
6464
}
6565

6666
- (NSArray * _Nullable)cachedIndirectNotifications {
67-
return [OneSignalUserDefaults.initShared getSavedCodeableDataForKey:OSUD_CACHED_INDIRECT_NOTIFICATION_IDS defaultValue:nil];
67+
return [OneSignalUserDefaults.initShared getSavedObjectForKey:OSUD_CACHED_INDIRECT_NOTIFICATION_IDS defaultValue:nil];
6868
}
6969

7070
- (void)saveNotifications:(NSArray *)notifications {
@@ -75,14 +75,6 @@ - (NSArray * _Nullable)lastNotificationsReceivedData {
7575
return [OneSignalUserDefaults.initShared getSavedCodeableDataForKey:OSUD_CACHED_RECEIVED_NOTIFICATION_IDS defaultValue:nil];
7676
}
7777

78-
- (void)cacheIndirectIAMs:(NSArray *)notifications {
79-
[OneSignalUserDefaults.initShared saveCodeableDataForKey:OSUD_CACHED_INDIRECT_NOTIFICATION_IDS withValue:notifications];
80-
}
81-
82-
- (NSArray * _Nullable)cachedIndirectIAMs {
83-
return [OneSignalUserDefaults.initShared getSavedCodeableDataForKey:OSUD_CACHED_INDIRECT_NOTIFICATION_IDS defaultValue:nil];
84-
}
85-
8678
- (void)saveIAMs:(NSArray *)iams {
8779
[OneSignalUserDefaults.initShared saveCodeableDataForKey:OSUD_CACHED_RECEIVED_IAM_IDS withValue:iams];
8880
}

iOS_SDK/OneSignalSDK/Source/OSMigrationController.m

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,44 @@ of this software and associated documentation files (the "Software"), to deal
2626
*/
2727

2828
#import <Foundation/Foundation.h>
29-
#import "OneSignal.h"
3029
#import "OSMigrationController.h"
30+
#import "OSInfluenceDataRepository.h"
3131
#import "OSIndirectInfluence.h"
32+
#import "OneSignal.h"
33+
#import "OneSignalUserDefaults.h"
34+
#import "OneSignalCommonDefines.h"
35+
#import "OneSignalHelper.h"
36+
37+
@interface OneSignal ()
38+
+ (OSInfluenceDataRepository *)influenceDataRepository;
39+
@end
3240

3341
@implementation OSMigrationController
3442

3543
- (void)migrate {
3644
[self migrateToVersion_02_14_00_AndGreater];
45+
[self saveCurrentSDKVersion];
3746
}
3847

3948
/**
4049
* Support renaming of decodable classes for cached data
4150
*/
4251
- (void)migrateToVersion_02_14_00_AndGreater {
43-
[NSKeyedUnarchiver setClass:[OSIndirectInfluence class] forClassName:@"OSIndirectNotification"];
52+
let influenceVersion = 21400;
53+
let sdkVersion = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
54+
if (sdkVersion < influenceVersion) {
55+
[OneSignal onesignal_Log:ONE_S_LL_DEBUG message:[NSString stringWithFormat:@"Migrating from version : %d", sdkVersion]];
56+
57+
[NSKeyedUnarchiver setClass:[OSIndirectInfluence class] forClassName:@"OSIndirectNotification"];
58+
NSArray<OSIndirectInfluence *> * indirectInfluenceData = [[OneSignal influenceDataRepository] lastNotificationsReceivedData];
59+
if (indirectInfluenceData)
60+
[[OneSignal influenceDataRepository] saveNotifications:indirectInfluenceData];
61+
}
62+
}
63+
64+
- (void)saveCurrentSDKVersion {
65+
let currentVersion = [[OneSignal sdk_version_raw] intValue];
66+
[OneSignalUserDefaults.initShared saveIntegerForKey:OSUD_CACHED_SDK_VERSION withValue:currentVersion];
4467
}
4568

4669
@end

iOS_SDK/OneSignalSDK/Source/OSNotificationTracker.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ - (OSInfluenceChannel)channelType {
4545
return NOTIFICATION;
4646
}
4747

48-
- (NSArray * _Nonnull)lastChannelObjectsReceivedByNewId:(NSString *)identifier {
48+
- (NSArray * _Nullable)lastChannelObjectsReceivedByNewId:(NSString *)identifier {
4949
return [self lastChannelObjects];
5050
}
5151

52-
- (NSArray * _Nonnull)lastChannelObjects {
52+
- (NSArray * _Nullable)lastChannelObjects {
5353
return [self.dataRepository lastNotificationsReceivedData];
5454
}
5555

iOS_SDK/OneSignalSDK/Source/OneSignalCommonDefines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
#define OSUD_CACHED_RECEIVED_IAM_IDS @"OSUD_CACHED_RECEIVED_IAM_IDS"
9797
#define OSUD_CACHED_UNATTRIBUTED_UNIQUE_OUTCOME_EVENTS_SENT @"CACHED_UNATTRIBUTED_UNIQUE_OUTCOME_EVENTS_SENT" // * OSUD_CACHED_UNATTRIBUTED_UNIQUE_OUTCOME_EVENTS_SENT
9898
#define OSUD_CACHED_ATTRIBUTED_UNIQUE_OUTCOME_EVENT_NOTIFICATION_IDS_SENT @"CACHED_ATTRIBUTED_UNIQUE_OUTCOME_EVENT_NOTIFICATION_IDS_SENT" // * OSUD_CACHED_ATTRIBUTED_UNIQUE_OUTCOME_EVENT_NOTIFICATION_IDS_SENT
99+
// Migration
100+
#define OSUD_CACHED_SDK_VERSION @"OSUD_CACHED_SDK_VERSION"
99101
// Time Tracking
100102
#define OSUD_APP_LAST_CLOSED_TIME @"GT_LAST_CLOSED_TIME" // * OSUD_APP_LAST_CLOSED_TIME
101103
#define OSUD_UNSENT_ACTIVE_TIME @"GT_UNSENT_ACTIVE_TIME" // * OSUD_UNSENT_ACTIVE_TIME
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
* Modified MIT License
3+
*
4+
* Copyright 2020 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
#import <XCTest/XCTest.h>
29+
#import "OSMigrationController.h"
30+
#import "OSInfluenceDataRepository.h"
31+
#import "OSIndirectInfluence.h"
32+
#import "OSIndirectNotification.h"
33+
#import "OneSignalHelper.h"
34+
#import "UnitTestCommonMethods.h"
35+
#import "OneSignalUserDefaults.h"
36+
#import "OneSignalCommonDefines.h"
37+
#import "CommonAsserts.h"
38+
39+
@interface MigrationTests : XCTestCase
40+
@end
41+
42+
@implementation MigrationTests {
43+
OSMigrationController *migrationController;
44+
OSInfluenceDataRepository *dataRepository;
45+
}
46+
47+
- (void)setUp {
48+
[super setUp];
49+
[UnitTestCommonMethods beforeEachTest:self];
50+
migrationController = [OSMigrationController new];
51+
dataRepository = [OSInfluenceDataRepository new];
52+
}
53+
54+
- (void)testNoIndirectInfluenceDataAvailableToMigrate {
55+
NSArray *lastNotificationReceived = [dataRepository lastNotificationsReceivedData];
56+
NSInteger sdkVersion = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
57+
XCTAssertNil(lastNotificationReceived);
58+
XCTAssertEqual(0, sdkVersion);
59+
[migrationController migrate];
60+
61+
NSArray *lastNotificationReceivedAfterMigration = [dataRepository lastNotificationsReceivedData];
62+
XCTAssertNil(lastNotificationReceivedAfterMigration);
63+
64+
NSInteger sdkVersionAfterMigration = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
65+
XCTAssertEqual([[OneSignal sdk_version_raw] intValue], sdkVersionAfterMigration);
66+
}
67+
68+
- (void)testIndirectNotificationToIndirectInfluenceMigration {
69+
NSString *notificationId = @"1234-5678-1234-5678-1234";
70+
double timestamp = 10;
71+
OSIndirectNotification *indirectNotification = [[OSIndirectNotification alloc] initWithParamsNotificationId:notificationId timestamp:timestamp];
72+
NSMutableArray *indirectNotifications = [NSMutableArray new];
73+
[indirectNotifications addObject:indirectNotification];
74+
75+
[dataRepository saveNotifications:indirectNotifications];
76+
NSArray *lastNotificationReceived = [dataRepository lastNotificationsReceivedData];
77+
NSInteger sdkVersion = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
78+
XCTAssertEqual(1, [lastNotificationReceived count]);
79+
XCTAssertEqual(0, sdkVersion);
80+
81+
[migrationController migrate];
82+
83+
NSArray<OSIndirectInfluence *> *lastNotificationReceivedAfterMigration = [dataRepository lastNotificationsReceivedData];
84+
XCTAssertEqual(1, [lastNotificationReceivedAfterMigration count]);
85+
86+
OSIndirectInfluence *indirectInfluence = [lastNotificationReceivedAfterMigration objectAtIndex:0];
87+
XCTAssertTrue([indirectInfluence.influenceId isEqualToString:notificationId]);
88+
XCTAssertTrue([indirectInfluence.channelIdTag isEqualToString:@"notification_id"]);
89+
XCTAssertEqual(timestamp, indirectInfluence.timestamp);
90+
91+
NSInteger sdkVersionAfterMigration = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
92+
XCTAssertEqual([[OneSignal sdk_version_raw] intValue], sdkVersionAfterMigration);
93+
}
94+
95+
- (void)testIndirectInfluenceToIndirectInfluenceMigration {
96+
NSString *notificationId = @"1234-5678-1234-5678-1234";
97+
NSString *channelId = @"notification_id";
98+
double timestamp = 10;
99+
OSIndirectInfluence *indirectInfluence = [[OSIndirectInfluence alloc] initWithParamsInfluenceId:notificationId forChannel:channelId timestamp:timestamp];
100+
NSMutableArray *indirectNotifications = [NSMutableArray new];
101+
[indirectNotifications addObject:indirectInfluence];
102+
103+
[dataRepository saveNotifications:indirectNotifications];
104+
NSArray *lastNotificationReceived = [dataRepository lastNotificationsReceivedData];
105+
NSInteger sdkVersion = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
106+
XCTAssertEqual(1, [lastNotificationReceived count]);
107+
XCTAssertEqual(0, sdkVersion);
108+
109+
[migrationController migrate];
110+
111+
NSArray<OSIndirectInfluence *> *lastNotificationReceivedAfterMigration = [dataRepository lastNotificationsReceivedData];
112+
XCTAssertEqual(1, [lastNotificationReceivedAfterMigration count]);
113+
114+
OSIndirectInfluence *indirectInfluenceAfterMigration = [lastNotificationReceivedAfterMigration objectAtIndex:0];
115+
XCTAssertTrue([indirectInfluenceAfterMigration.influenceId isEqualToString:notificationId]);
116+
XCTAssertTrue([indirectInfluenceAfterMigration.channelIdTag isEqualToString:channelId]);
117+
XCTAssertEqual(timestamp, indirectInfluenceAfterMigration.timestamp);
118+
119+
NSInteger sdkVersionAfterMigration = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
120+
XCTAssertEqual([[OneSignal sdk_version_raw] intValue], sdkVersionAfterMigration);
121+
}
122+
123+
@end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
Modified MIT License
3+
4+
Copyright 2019 OneSignal
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
1. The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
2. All copies of substantial portions of the Software may only be used in connection
17+
with services provided by OneSignal.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+
*/
27+
28+
29+
#import "OSJSONHandling.h"
30+
31+
@interface OSIndirectNotification : NSObject <NSCoding, OSJSONEncodable, OSJSONDecodable>
32+
33+
@property (nonatomic, readonly) NSString *notificationId;
34+
@property (nonatomic, readonly) double timestamp; // seconds
35+
36+
- (id)initWithParamsNotificationId:(NSString *)notificationId timestamp:(double)timestamp;
37+
38+
@end

0 commit comments

Comments
 (0)