Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FirebaseMessaging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [fixed] Migrate FCM codebase to new NSKeyedUnarchiver APIs. (#14424).

# 11.8.0
- [fixed] Don't cache FCM registration token operations. (#14352).

Expand Down
12 changes: 6 additions & 6 deletions FirebaseMessaging/Sources/Token/FIRMessagingTokenInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
// users have upgraded to at least 10.19.0. Perhaps, after privacy manifests have been required
// for awhile?
@try {
[NSKeyedUnarchiver setClass:[FIRMessagingAPNSInfo class]
forClassName:@"FIRInstanceIDAPNSInfo"];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
rawAPNSInfo = [NSKeyedUnarchiver unarchiveObjectWithData:(NSData *)rawAPNSInfo];
NSKeyedUnarchiver *unarchiver =
[[NSKeyedUnarchiver alloc] initForReadingFromData:(NSData *)rawAPNSInfo error:nil];
unarchiver.requiresSecureCoding = NO;
[unarchiver setClass:[FIRMessagingAPNSInfo class] forClassName:@"FIRInstanceIDAPNSInfo"];
rawAPNSInfo = [unarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
[unarchiver finishDecoding];
needsMigration = YES;
#pragma clang diagnostic pop
} @catch (NSException *exception) {
FIRMessagingLoggerInfo(kFIRMessagingMessageCodeTokenInfoBadAPNSInfo,
@"Could not parse raw APNS Info while parsing archived token info.");
Expand Down
17 changes: 6 additions & 11 deletions FirebaseMessaging/Sources/Token/FIRMessagingTokenStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,14 @@ - (nullable FIRMessagingTokenInfo *)tokenInfoWithAuthorizedEntity:(NSString *)au
+ (nullable FIRMessagingTokenInfo *)tokenInfoFromKeychainItem:(NSData *)item {
// Check if it is saved as an archived FIRMessagingTokenInfo, otherwise return nil.
FIRMessagingTokenInfo *tokenInfo = nil;
// NOTE: Passing in nil to unarchiveObjectWithData will result in an iOS error logged
// in the console on iOS 10 and below. Avoid by checking item.data's existence.
if (item) {
// TODO(chliangGoogle: Use the new API and secureCoding protocol.
@try {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[NSKeyedUnarchiver setClass:[FIRMessagingTokenInfo class]
forClassName:@"FIRInstanceIDTokenInfo"];
tokenInfo = [NSKeyedUnarchiver unarchiveObjectWithData:item];

#pragma clang diagnostic pop

NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:item
error:nil];
unarchiver.requiresSecureCoding = NO;
[unarchiver setClass:[FIRMessagingTokenInfo class] forClassName:@"FIRInstanceIDTokenInfo"];
tokenInfo = [unarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
[unarchiver finishDecoding];
} @catch (NSException *exception) {
FIRMessagingLoggerDebug(kFIRMessagingMessageCodeTokenStoreExceptionUnarchivingTokenInfo,
@"Unable to parse token info from Keychain item; item was in an "
Expand Down
Loading