Skip to content

Commit cab2d76

Browse files
authored
Merge pull request #997 from OneSignal/fix/OSInAppMessageInternal_Migration
Fix OSInAppMessageInternal migration crash
2 parents 8df1277 + 6f71c9d commit cab2d76

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

iOS_SDK/OneSignalSDK/Source/OSMigrationController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ - (void)migrateIAMRedisplayCache {
118118
- (void)migrateToOSInAppMessageInternal {
119119
let nameChangeVersion = 30700;
120120
long sdkVersion = [OneSignalUserDefaults.initShared getSavedIntegerForKey:OSUD_CACHED_SDK_VERSION defaultValue:0];
121+
[NSKeyedUnarchiver setClass:[OSInAppMessageInternal class] forClassName:@"OSInAppMessage"];
121122
if (sdkVersion < nameChangeVersion) {
122123
[OneSignal onesignal_Log:ONE_S_LL_DEBUG message:[NSString stringWithFormat:@"Migrating OSInAppMessage from version: %ld", sdkVersion]];
123124

iOS_SDK/OneSignalSDK/UnitTests/MigrationTests.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ - (void)testIAMNilCacheToNilMigration {
288288
XCTAssertNil(retrievedDict);
289289
}
290290

291-
- (void)testIAMToInternalMigration {
291+
- (void)testIAMMessagesToInternalMigration {
292292
let limit = 5;
293293
let delay = 60;
294294
let message = [OSInAppMessageTestHelper testMessageWithRedisplayLimit:limit delay:@(delay)];
@@ -306,7 +306,13 @@ - (void)testIAMToInternalMigration {
306306
NSArray<OSInAppMessageInternal *>*retrievedArray = [OneSignalUserDefaults.initStandard
307307
getSavedCodeableDataForKey:OS_IAM_MESSAGES_ARRAY defaultValue:nil];
308308
XCTAssertEqualObjects(messages, retrievedArray);
309-
309+
}
310+
311+
- (void)testIAMRedisplayToInternalMigration {
312+
let limit = 5;
313+
let delay = 60;
314+
let message = [OSInAppMessageTestHelper testMessageWithRedisplayLimit:limit delay:@(delay)];
315+
message.isDisplayedInSession = true;
310316
// Cached Redisplay Messages
311317
NSMutableDictionary <NSString *, OSInAppMessageInternal *> *redisplayedInAppMessages = [NSMutableDictionary new];
312318
[redisplayedInAppMessages setObject:message forKey:message.messageId];
@@ -323,7 +329,4 @@ - (void)testIAMToInternalMigration {
323329
}
324330

325331

326-
327-
328-
329332
@end

0 commit comments

Comments
 (0)