Reputation: 101
I want to clean the User AuthData Saved in Mobile upon uninstall. AuthData is saved using AsyncStorage. Is there any mechanism by which I can detect App Uninstall in ReactNative
Upvotes: 7
Views: 8270
Reputation: 500
For me worked this solution (swift code): https://stackoverflow.com/a/40732677/3151214
Variable userDefaults (NSUserDefaults
) can be accessed through Settings
in React Native, so javascript implemetation can be looked like:
import { Platform, Settings } from 'react-native';
function getAuthData() {
let isStoreNeedCleaning = false;
if (Platform.OS === 'ios') {
if (!Settings.get('hasRunBefore')) {
Settings.set({ hasRunBefore: true });
isStoreNeedCleaning = true;
}
}
if (isStoreNeedCleaning) {
// Clean up your store
} else {
// Load auth data from store
}
}
Upvotes: 0
Reputation: 9684
Doesn't seem possible, especially if your app is not running at the time they uninstall. However, there seems to be a couple approaches you can take, but neither is perfect.
UIApplicationWillTerminateNotification
(see Detect iOS application about to delete?)Upvotes: 2