@@ -48,18 +48,15 @@ - (instancetype)initWithAction:(FIRMessagingTopicAction)action {
48
48
return self;
49
49
}
50
50
51
- #pragma mark NSSecureCoding
52
-
53
- + (BOOL )supportsSecureCoding {
54
- return YES ;
55
- }
51
+ #pragma mark NSCoding
56
52
57
53
- (void )encodeWithCoder : (NSCoder *)aCoder {
58
54
[aCoder encodeInteger: self .action forKey: kPendingTopicBatchActionKey ];
59
55
[aCoder encodeObject: self .topics forKey: kPendingTopicBatchTopicsKey ];
60
56
}
61
57
62
58
- (instancetype )initWithCoder : (NSCoder *)aDecoder {
59
+
63
60
// Ensure that our integer -> enum casting is safe
64
61
NSInteger actionRawValue = [aDecoder decodeIntegerForKey: kPendingTopicBatchActionKey ];
65
62
FIRMessagingTopicAction action = FIRMessagingTopicActionSubscribe;
@@ -68,7 +65,10 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
68
65
}
69
66
70
67
if (self = [self initWithAction: action]) {
71
- _topics = [aDecoder decodeObjectOfClass: [NSSet class ] forKey: kPendingTopicBatchTopicsKey ];
68
+ NSSet *topics = [aDecoder decodeObjectForKey: kPendingTopicBatchTopicsKey ];
69
+ if ([topics isKindOfClass: [NSSet class ]]) {
70
+ _topics = [topics mutableCopy ];
71
+ }
72
72
_topicHandlers = [NSMutableDictionary dictionary ];
73
73
}
74
74
return self;
@@ -109,22 +109,20 @@ + (void)pruneTopicBatches:(NSMutableArray <FIRMessagingTopicBatch *> *)topicBatc
109
109
}
110
110
}
111
111
112
- #pragma mark NSSecureCoding
113
-
114
- + (BOOL )supportsSecureCoding {
115
- return YES ;
116
- }
112
+ #pragma mark NSCoding
117
113
118
114
- (void )encodeWithCoder : (NSCoder *)aCoder {
119
115
[aCoder encodeObject: [NSDate date ] forKey: kPendingTopicsTimestampEncodingKey ];
120
116
[aCoder encodeObject: self .topicBatches forKey: kPendingBatchesEncodingKey ];
121
117
}
122
118
123
119
- (nullable instancetype )initWithCoder : (NSCoder *)aDecoder {
120
+
124
121
if (self = [self init ]) {
125
- _archiveDate = [aDecoder decodeObjectOfClass: [NSDate class ] forKey: kPendingTopicsTimestampEncodingKey ];
126
- _topicBatches = [aDecoder decodeObjectOfClass: [NSMutableArray <FIRMessagingTopicBatch *> class] forKey: kPendingBatchesEncodingKey ];
127
- if (_topicBatches) {
122
+ _archiveDate = [aDecoder decodeObjectForKey: kPendingTopicsTimestampEncodingKey ];
123
+ NSArray *archivedBatches = [aDecoder decodeObjectForKey: kPendingBatchesEncodingKey ];
124
+ if (archivedBatches) {
125
+ _topicBatches = [archivedBatches mutableCopy ];
128
126
[FIRMessagingPendingTopicsList pruneTopicBatches: _topicBatches];
129
127
}
130
128
_topicsInFlight = [NSMutableSet set ];
0 commit comments