-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
192 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,4 +110,5 @@ dist | |
test.js | ||
test.ts | ||
test.jsx | ||
test.tsx | ||
test.tsx | ||
android/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Constants from 'expo-constants'; | ||
|
||
export const getVersion = () => { | ||
return Constants.expoConfig?.version; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Constants from 'expo-constants'; | ||
import { Platform } from 'react-native'; | ||
import SpInAppUpdates, { | ||
AndroidInAppUpdateExtras, | ||
AndroidInstallStatus, | ||
IAUUpdateKind, | ||
StartUpdateOptions, | ||
} from 'sp-react-native-in-app-updates'; | ||
|
||
const HIGH_PRIORITY_UPDATE = 5; // Arbitrary, depends on how you handle priority in the Play Console | ||
export const checkUpdate = () => { | ||
const inAppUpdates = new SpInAppUpdates(false); | ||
console.log('[INAPP] Checking store version'); | ||
inAppUpdates.checkNeedsUpdate({ curVersion: Constants.expoConfig.version }).then((result) => { | ||
console.log('[INAPP] result: ' + JSON.stringify(result)); | ||
if (result.shouldUpdate) { | ||
if (Platform.OS === 'android') { | ||
const updateOptions: StartUpdateOptions = { | ||
updateType: | ||
(result?.other as AndroidInAppUpdateExtras)?.updatePriority <= HIGH_PRIORITY_UPDATE // TODO: implement flexible | ||
? IAUUpdateKind.IMMEDIATE | ||
: IAUUpdateKind.FLEXIBLE, | ||
}; | ||
if (updateOptions.updateType === IAUUpdateKind.FLEXIBLE) { | ||
inAppUpdates.addStatusUpdateListener((ev) => { | ||
console.debug(`[INAPP] status: ${JSON.stringify(ev)}`); | ||
if (ev.status === AndroidInstallStatus.DOWNLOADED) console.log('[INAPP] downloaded'); | ||
}); | ||
} | ||
inAppUpdates.startUpdate(updateOptions); // https://github.com/SudoPlz/sp-react-native-in-app-updates/blob/master/src/types.ts#L78 | ||
} | ||
} | ||
}); | ||
return inAppUpdates; | ||
}; | ||
|
||
export const installUpdate = (spInAppUpdates: SpInAppUpdates) => spInAppUpdates.installUpdate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters