Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode old fcmToken format #12246

Merged
merged 5 commits into from
Jan 6, 2024
Merged
Changes from 1 commit
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
16 changes: 15 additions & 1 deletion FirebaseMessaging/Sources/Token/FIRMessagingTokenInfo.m
paulb777 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,21 @@ - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
FIRMessagingAPNSInfo *rawAPNSInfo = [aDecoder decodeObjectOfClasses:classes
forKey:kFIRInstanceIDAPNSInfoKey];
if (rawAPNSInfo && ![rawAPNSInfo isKindOfClass:[FIRMessagingAPNSInfo class]]) {
return nil;
// If the decoder fails to decode a FIRMessagingAPNSInfo, check if this was archived by a
// FirebaseMessaging 10.18.0 or earlier.
@try {
[NSKeyedUnarchiver setClass:[FIRMessagingAPNSInfo class]
forClassName:@"FIRInstanceIDAPNSInfo"];
paulb777 marked this conversation as resolved.
Show resolved Hide resolved
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
rawAPNSInfo = [NSKeyedUnarchiver unarchiveObjectWithData:(NSData *)rawAPNSInfo];
paulb777 marked this conversation as resolved.
Show resolved Hide resolved
#pragma clang diagnostic pop
} @catch (NSException *exception) {
FIRMessagingLoggerInfo(kFIRMessagingMessageCodeTokenInfoBadAPNSInfo,
@"Could not parse raw APNS Info while parsing archived token info.");
rawAPNSInfo = nil;
} @finally {
}
}

id cacheTime = [aDecoder decodeObjectForKey:kFIRInstanceIDCacheTimeKey];
Expand Down
Loading