Skip to content

Commit 989f71c

Browse files
committed
Fix NSInvalidUnarchiveOperationException due to decodable class renamed
* Add migration class for future cases
1 parent b19c2f9 commit 989f71c

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@
9999
7A9173A2231971E5007848FA /* OneSignalReceiveReceiptsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A9173A1231971E5007848FA /* OneSignalReceiveReceiptsController.m */; };
100100
7AA2848A2406FC6400C25D76 /* OSInAppMessageTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A1F2D8E2406EFC5007799A9 /* OSInAppMessageTag.m */; };
101101
7AA2848B2406FC6500C25D76 /* OSInAppMessageTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A1F2D8E2406EFC5007799A9 /* OSInAppMessageTag.m */; };
102+
7AAA60662485D0310004FADE /* OSMigrationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AAA60652485D0090004FADE /* OSMigrationController.h */; };
103+
7AAA60682485D0420004FADE /* OSMigrationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AAA60672485D0420004FADE /* OSMigrationController.m */; };
104+
7AAA60692485D0420004FADE /* OSMigrationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AAA60672485D0420004FADE /* OSMigrationController.m */; };
105+
7AAA606A2485D0420004FADE /* OSMigrationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AAA60672485D0420004FADE /* OSMigrationController.m */; };
102106
7ABAF9D22457C3650074DFA0 /* CommonAsserts.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ABAF9D12457C3650074DFA0 /* CommonAsserts.m */; };
103107
7ABAF9D32457C4620074DFA0 /* CommonAsserts.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ABAF9D02457C3570074DFA0 /* CommonAsserts.h */; };
104108
7ABAF9D62457D3FF0074DFA0 /* ChannelTrackersTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ABAF9D52457D3FF0074DFA0 /* ChannelTrackersTests.m */; };
@@ -488,6 +492,8 @@
488492
7A880F302404AE7B0081F5E8 /* OSInAppMessagePushPrompt.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSInAppMessagePushPrompt.m; sourceTree = "<group>"; };
489493
7A9173A1231971E5007848FA /* OneSignalReceiveReceiptsController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OneSignalReceiveReceiptsController.m; sourceTree = "<group>"; };
490494
7A9173A3231971F8007848FA /* OneSignalReceiveReceiptsController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalReceiveReceiptsController.h; sourceTree = "<group>"; };
495+
7AAA60652485D0090004FADE /* OSMigrationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSMigrationController.h; sourceTree = "<group>"; };
496+
7AAA60672485D0420004FADE /* OSMigrationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSMigrationController.m; sourceTree = "<group>"; };
491497
7ABAF9D02457C3570074DFA0 /* CommonAsserts.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommonAsserts.h; sourceTree = "<group>"; };
492498
7ABAF9D12457C3650074DFA0 /* CommonAsserts.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CommonAsserts.m; sourceTree = "<group>"; };
493499
7ABAF9D52457D3FF0074DFA0 /* ChannelTrackersTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChannelTrackersTests.m; sourceTree = "<group>"; };
@@ -842,6 +848,15 @@
842848
name = ReceiveReceipts;
843849
sourceTree = "<group>";
844850
};
851+
7AAA606B2485D0D70004FADE /* migration */ = {
852+
isa = PBXGroup;
853+
children = (
854+
7AAA60652485D0090004FADE /* OSMigrationController.h */,
855+
7AAA60672485D0420004FADE /* OSMigrationController.m */,
856+
);
857+
name = migration;
858+
sourceTree = "<group>";
859+
};
845860
7ABAF9D42457D3160074DFA0 /* Model */ = {
846861
isa = PBXGroup;
847862
children = (
@@ -961,6 +976,7 @@
961976
912411EE1E73342200E41FD7 /* Source */ = {
962977
isa = PBXGroup;
963978
children = (
979+
7AAA606B2485D0D70004FADE /* migration */,
964980
7AF98632243F84AC00C36EAE /* Influence */,
965981
7A674F172360D7DB001F9ACD /* OnFocus */,
966982
7ADE379222E8B56F00263048 /* OutcomeEvents */,
@@ -1199,6 +1215,7 @@
11991215
buildActionMask = 2147483647;
12001216
files = (
12011217
CACBAA96218A6243000ACAA5 /* OSInAppMessageViewController.h in Headers */,
1218+
7AAA60662485D0310004FADE /* OSMigrationController.h in Headers */,
12021219
CA47439D2190FEA80020DC8C /* OSTrigger.h in Headers */,
12031220
7A1232A4235E175C002B6CE3 /* OneSignalOutcomeEventsController.h in Headers */,
12041221
7AF98690244A566F00C36EAE /* OSOutcomeEventsCache.h in Headers */,
@@ -1462,6 +1479,7 @@
14621479
9129C6B81E89E59B009CB6A0 /* OSPermission.m in Sources */,
14631480
CA8E19062193C76D009DA223 /* OSInAppMessagingHelpers.m in Sources */,
14641481
7AF98664244975AD00C36EAE /* OSOutcomeSourceBody.m in Sources */,
1482+
7AAA60682485D0420004FADE /* OSMigrationController.m in Sources */,
14651483
7A12EBDD23060B37005C4FA5 /* OSIndirectInfluence.m in Sources */,
14661484
9D1BD96D237B57CA00A064F7 /* OneSignalCacheCleaner.m in Sources */,
14671485
7A674F1B2360D82E001F9ACD /* OSBaseFocusTimeProcessor.m in Sources */,
@@ -1549,6 +1567,7 @@
15491567
9129C6B91E89E59B009CB6A0 /* OSPermission.m in Sources */,
15501568
9D1BD96E237B57CA00A064F7 /* OneSignalCacheCleaner.m in Sources */,
15511569
7AF98665244975AD00C36EAE /* OSOutcomeSourceBody.m in Sources */,
1570+
7AAA60692485D0420004FADE /* OSMigrationController.m in Sources */,
15521571
7A1232AB235E17B8002B6CE3 /* OneSignalOutcomeEventsController.m in Sources */,
15531572
CA36A42E208FDEFB003EFA9A /* NSURL+OneSignal.m in Sources */,
15541573
912412131E73342200E41FD7 /* OneSignalAlertViewDelegate.m in Sources */,
@@ -1703,6 +1722,7 @@
17031722
7AF9868E244A556F00C36EAE /* OSOutcomeEventsFactory.m in Sources */,
17041723
7AF986452444C47400C36EAE /* OSNotificationTracker.m in Sources */,
17051724
7A72EB1023E252C700B4D50F /* OSInAppMessageDisplayStats.m in Sources */,
1725+
7AAA606A2485D0420004FADE /* OSMigrationController.m in Sources */,
17061726
CACBAA9F218A6243000ACAA5 /* OSInAppMessageView.m in Sources */,
17071727
CA4742E7218B8FF30020DC8C /* OSTriggerController.m in Sources */,
17081728
4529DEEA1FA8360C00CEAB1D /* UIApplicationOverrider.m in Sources */,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 "OneSignal.h"
29+
30+
#ifndef OSMigrationController_h
31+
#define OSMigrationController_h
32+
33+
@interface OSMigrationController : NSObject
34+
35+
- (void)migrate;
36+
37+
@end
38+
39+
#endif /* OSMigrationController_h */
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 <Foundation/Foundation.h>
29+
#import "OneSignal.h"
30+
#import "OSMigrationController.h"
31+
#import "OSIndirectInfluence.h"
32+
33+
@implementation OSMigrationController
34+
35+
- (void)migrate {
36+
[self migrateToVersion_02_14_00_AndGreater];
37+
}
38+
39+
/**
40+
* Support renaming of decodable classes for cached data
41+
*/
42+
- (void)migrateToVersion_02_14_00_AndGreater {
43+
[NSKeyedUnarchiver setClass:[OSIndirectInfluence class] forClassName:@"OSIndirectNotification"];
44+
}
45+
46+
@end

iOS_SDK/OneSignalSDK/Source/OneSignal.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#import "OneSignalCommonDefines.h"
4848
#import "OneSignalUserDefaults.h"
4949
#import "OneSignalCacheCleaner.h"
50+
#import "OSMigrationController.h"
5051

5152
#import "OneSignalNotificationSettings.h"
5253
#import "OneSignalNotificationSettingsIOS10.h"
@@ -551,7 +552,7 @@ + (id)initWithLaunchOptions:(NSDictionary*)launchOptions
551552
settings:(NSDictionary*)settings {
552553

553554
[self onesignal_Log:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"Called init with app ID: %@", appId]];
554-
555+
[[OSMigrationController new] migrate];
555556
[OneSignalHelper setNotificationActionBlock:actionCallback];
556557
[OneSignalHelper setNotificationReceivedBlock:receivedCallback];
557558

0 commit comments

Comments
 (0)