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