Reputation: 43
Maven,
I have an app in react native and redux. I want to log out the users when they update the app from any of the stores. Is there a way to achieve this ?
Upvotes: 1
Views: 2086
Reputation: 1
DeviceInfo.getSupportedMediaTypeList().then((string[]) => {
// ["audio/mpeg", "audio/mp4a-latm", "audio/mp4a-latm", "audio/mp4a-latm", "audio/mp4a-latm", "video/avc", "video/3gpp", "video/hevc", "video/mp4v-es", "video/av01", "video/avc", "video/avc", "video/avc", "video/avc"]
});
Upvotes: 0
Reputation: 2573
One way to do it is to save the version number in AsyncStorage and every time the app opens you compare between the current version number and the number stored, if you found a difference then you will know the user updated.
Also you will need to install DeviceInfo package
Here's how:
import React from 'react'
import DeviceInfo from 'react-native-device-info'
import { AsyncStorage } from 'react-native'
// Your root class component
class App extends React.Component {
async componentDidMount() {
try {
const lastSavedVersionNumber = await AsyncStorage.getItem('appVersionNumber')
if (!!lastSavedVersionNumber) { // Validate the value if it's really there
if (lastSavedVersionNumber !== DeviceInfo.getVersion()) {
// The user has updated the app because the numbers doesn't match
// Set the new version number then logout
AsyncStorage.setItem('appVersionNumber', DeviceInfo.getVersion())
// ... logout here
}
} else {
// Value doesn't exist, need to set it for the first time
AsyncStorage.setItem('appVersionNumber', DeviceInfo.getVersion())
}
} catch (error) {
}
}
}
Upvotes: 2