-
Notifications
You must be signed in to change notification settings - Fork 292
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
Crash on logout call to Firebase auth with proceeding Purchases.shared.reset #151
Comments
Are you by any chance clearing NSUserDefaults when signing out the user? |
Yes! |
We hadn't considered somebody deleting our cache keys from underneath us mid-session. Doing so will leave the SDK in a state that can only be fixed by calling Can you, instead of clearing the whole NSUserDefaults, remove the specific keys you are using? |
Thanks! Of course, I could, but isn't it a bit dangerous as a third party SDK to rely upon NSUserDefaults:
🤔 Not trying to be difficult, I will of course remedy this crash by doing as you propose. Just want to have a discussion so I can learn about your reasoning as a third party SDK developer 😃. |
@heumn Sorry for the delay in the response. You're right, relying on |
@heumn update on this: The SDK allows for you to specify a separate instance of Here's an example of sending in a different user defaults instance for the RevenueCat SDK: guard let revenueCatUserDefaults = UserDefaults.init(suiteName: "com.myapp.revenuecat") else {
fatalError("can't create user defaults for RevenueCat domain")
}
Purchases.configure(withAPIKey: "your api key here",
appUserID: nil,
observerMode: false,
userDefaults: revenueCatUserDefaults)
Important: Make sure that the domain that you use to instantiate the NSUserDefaults passed into RevenueCat is different from the domain of the main bundle of your app. |
This makes much more sense :) Thanks for the update and thanks for an awesome service |
one last note here: if you change the domain on an existing app, the first time it runs, the SDK won't find the existing data, so it'll be the equivalent of calling |
closing for now, feel free to reopen if you run into any more issues with this |
Calling Auth.auth().signOut() crashes with the following stack trace if you have added an observer to
Auth.auth().addStateDidChangeListener
and call
Purchases.shared.reset
as per your guideI have enough bugs that I produce myself, so would be awesome to not have to deal with yours as well ;)
The text was updated successfully, but these errors were encountered: