Skip to content

fix: replace deprecated NSKeyedArchiver/NSKeyedUnarchiver APIs#1680

Open
garvitkaushik-123 wants to merge 1 commit into
OneSignal:mainfrom
garvitkaushik-123:fix/replace-deprecated-NSKeyedUnarchiver-api
Open

fix: replace deprecated NSKeyedArchiver/NSKeyedUnarchiver APIs#1680
garvitkaushik-123 wants to merge 1 commit into
OneSignal:mainfrom
garvitkaushik-123:fix/replace-deprecated-NSKeyedUnarchiver-api

Conversation

@garvitkaushik-123

Copy link
Copy Markdown

Summary

  • Replaces deprecated +[NSKeyedUnarchiver unarchiveObjectWithData:] with instance-based NSKeyedUnarchiver using initForReadingFromData:error: and decodeTopLevelObjectAndReturnError:
  • Replaces deprecated +[NSKeyedArchiver archivedDataWithRootObject:] with archivedDataWithRootObject:requiringSecureCoding:NO error:
  • Both modern APIs are available since iOS 11.0, which matches the SDK's minimum deployment target

The deprecated methods are flagged as unsafe by security scanners (CWE-676). Setting requiresSecureCoding = NO maintains backward compatibility with existing model classes that implement NSCoding.

Resolves #919

Test plan

  • Verify existing unit tests pass (archiving/unarchiving behavior is unchanged)
  • Verify migration flows (IAM redisplay cache, class name migrations) work correctly
  • Confirm no deprecation warnings from NSKeyedArchiver/NSKeyedUnarchiver in build output

…odern equivalents

The deprecated `+[NSKeyedUnarchiver unarchiveObjectWithData:]` and
`+[NSKeyedArchiver archivedDataWithRootObject:]` methods are flagged as
unsafe by security scanners (CWE-676). Replace them with instance-based
`NSKeyedUnarchiver` and `archivedDataWithRootObject:requiringSecureCoding:error:`
which are available since iOS 11.0 (the SDK minimum deployment target).

Resolves OneSignal#919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OneSignalUserDefaults uses NSKeyedUnarchiver method flagged as unsafe

1 participant