Skip to content

Commit 9a1ec13

Browse files
committed
De-duplicate code in migration controller
The migration controller's `migrateToVersion_02_14_00_AndGreater` method is the exact method as `[OSOutcomes migrate]`. This was duplicated unnecessarily during modularization of the SDK.
1 parent e16d2ba commit 9a1ec13

1 file changed

Lines changed: 1 addition & 37 deletions

File tree

iOS_SDK/OneSignalSDK/Source/OSMigrationController.m

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,47 +40,11 @@ + (OSOutcomeEventsCache *)outcomeEventsCache;
4040
@implementation OSMigrationController
4141

4242
- (void)migrate {
43-
[self migrateToVersion_02_14_00_AndGreater];
43+
[OSOutcomes migrate];
4444
let oneSignalInAppMessages = NSClassFromString(ONE_SIGNAL_IN_APP_MESSAGES_CLASS_NAME);
4545
if (oneSignalInAppMessages != nil && [oneSignalInAppMessages respondsToSelector:@selector(migrate)]) {
4646
[oneSignalInAppMessages performSelector:@selector(migrate)];
4747
}
48-
[self saveCurrentSDKVersion];
49-
}
50-
51-
/**
52-
* Support renaming of decodable classes for cached data
53-
*/
54-
- (void)migrateToVersion_02_14_00_AndGreater {
55-
let influenceVersion = 21400;
56-
let uniqueCacheOutcomeVersion = 21403;
57-
long sdkVersion = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
58-
if (sdkVersion < influenceVersion) {
59-
[OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:[NSString stringWithFormat:@"Migrating OSIndirectNotification from version: %ld", sdkVersion]];
60-
61-
[NSKeyedUnarchiver setClass:[OSIndirectInfluence class] forClassName:@"OSIndirectNotification"];
62-
NSArray<OSIndirectInfluence *> * indirectInfluenceData = [[OSInfluenceDataRepository sharedInfluenceDataRepository] lastNotificationsReceivedData];
63-
if (indirectInfluenceData) {
64-
[NSKeyedArchiver setClassName:@"OSIndirectInfluence" forClass:[OSIndirectInfluence class]];
65-
[[OSInfluenceDataRepository sharedInfluenceDataRepository] saveNotifications:indirectInfluenceData];
66-
}
67-
}
68-
69-
if (sdkVersion < uniqueCacheOutcomeVersion) {
70-
[OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:[NSString stringWithFormat:@"Migrating OSUniqueOutcomeNotification from version: %ld", sdkVersion]];
71-
72-
[NSKeyedUnarchiver setClass:[OSCachedUniqueOutcome class] forClassName:@"OSUniqueOutcomeNotification"];
73-
NSArray<OSCachedUniqueOutcome *> * attributedCacheUniqueOutcomeEvents = [[OSOutcomeEventsCache sharedOutcomeEventsCache] getAttributedUniqueOutcomeEventSent];
74-
if (attributedCacheUniqueOutcomeEvents) {
75-
[NSKeyedArchiver setClassName:@"OSCachedUniqueOutcome" forClass:[OSCachedUniqueOutcome class]];
76-
[[OSOutcomeEventsCache sharedOutcomeEventsCache] saveAttributedUniqueOutcomeEventNotificationIds:attributedCacheUniqueOutcomeEvents];
77-
}
78-
}
79-
}
80-
81-
- (void)saveCurrentSDKVersion {
82-
let currentVersion = [[OneSignal sdkVersionRaw] intValue];
83-
[OneSignalUserDefaults.initShared saveIntegerForKey:OSUD_CACHED_SDK_VERSION withValue:currentVersion];
8448
}
8549

8650
@end

0 commit comments

Comments
 (0)