Yes, you've to delay the API call for UserDefaults etc. till you receive callback like didFinishLaunching. If you try to access before it, sometimes you may get data and sometimes you may not. Same code was working fine in iOS14 and below.
Post
Replies
Boosts
Views
Activity
please make sure to call UserDefaults only after - appDidFinishLaunching. If you still see the issue amd are using UserDefaults.standard, then try creating a new instance of UserDefaults with your own suitename and use that instead of standard UserDefaults.