sp-react-native-in-app-updates: Failed to check or start update: [TypeError: Cannot read property 'checkNeedsUpdate' of null]
Don’t know why but I’m getting this error Although , I have installed it correctly & getting the inAppUpdates all props
import SpInAppUpdates, { NeedsUpdateResponse, IAUUpdateKind, StartUpdateOptions, } from “sp-react-native-in-app-updates”
SplashScreen.preventAutoHideAsync()
function IgniteApp() { const inAppUpdates = new SpInAppUpdates(false)
const checkAndUpdateApp = async () => { try { console.log(“Before checkNeedsUpdate:”, inAppUpdates) const result = await inAppUpdates.checkNeedsUpdate() console.log(“Update result:”, result)
if (result.shouldUpdate) {
let updateOptions: StartUpdateOptions = {}
if (Platform.OS === "android") {
updateOptions = {
updateType: IAUUpdateKind.IMMEDIATE,
}
await inAppUpdates.startUpdate(updateOptions)
} else {
console.log("Update available. Please visit the App Store to update the app.")
}
}
} catch (error) {
console.error("Failed to check or start update:", error)
}
}
React.useEffect(() => { async function onFetchUpdateAsync() { try { const update = await Updates.checkForUpdateAsync()
if (update.isAvailable) {
await Updates.fetchUpdateAsync()
await Updates.reloadAsync()
}
} catch (error) {
console.log("RTTTR", error)
alert(`Error fetching latest Expo update: ${error}`)
}
}
console.log("FFff-----", __DEV__)
if (!__DEV__) {
onFetchUpdateAsync()
}
checkAndUpdateApp()
}, [])
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 16 (1 by maintainers)
Got it, thank you! But I’m trying to use android in-app updates API,
react-native-store-versiononly makes fetch request@iliapnmrv is your app published ? make sure your app should be published
const check = await checkVersion({ androidStoreURL: "Your app url, country: “np”, }); try to console this with your app url and try with any playstore url “https://play.google.com/store/apps/details?id=com.dts.freefireth”
Thanks for that it has worked with this code