UserDefaults and link to Apple ID

Hi all, I am creating a little mobile game app, where users can sign in with their Apple ID (Sign in with Apple). During the onboarding, I also set some UserDefaults in @ AppStorage. As I code the signOut() feature, I am wondering if I need to set all the user back to their original "" or nil. I understand that for my deleteAccount() feature I will do this, but do I also have to do this for signOut()? The main reason I can think of having to do this, is if users change their Apple ID on the same device, re-download the app and then sign in - in which case the user defaults may be the same as set using the old Apple ID, right?

So my question is, does an app downloaded on the same device but with a different apple ID keep the original UserDefaults set for that app?

Having to set UserDefaults to nil is no big issue, but from a code efficiency standpoint was wondering if it was necessary.

Thank you for your help :)

You could just use GameCenter to manage this. User defaults is a convenient way of saving app settings in the app's sandbox. They don't remain if the user deletes the app. But if you save scores, progress, and achievements to their GameCenter account, those things stay with the account. I think there is no reason to roll your own system for this.

UserDefaults and link to Apple ID
 
 
Q