-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: install ktor * build: install app-update-ktx * feat: implement getVersionInfo and startUpdate * revert: ktor * refactor: folder structure
- Loading branch information
Showing
14 changed files
with
122 additions
and
20 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
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,18 @@ | ||
import { NativeModules } from 'react-native'; | ||
|
||
const neoVersion = NativeModules.NeoVersion; | ||
|
||
type VersionInfo = { | ||
isUpdateAvailable: boolean; | ||
stalenessDays: number; | ||
}; | ||
|
||
export function getVersionInfo(): Promise<Partial<VersionInfo>> { | ||
return neoVersion.getVersionInfo(); | ||
} | ||
|
||
export function startUpdate(): Promise<void> { | ||
return neoVersion.startUpdate(); | ||
} | ||
|
||
export default neoVersion; |
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,33 @@ | ||
import { useEffect } from 'react'; | ||
import { getVersionInfo, startUpdate } from './neoVersion.android'; | ||
import { Alert } from 'react-native'; | ||
import type { Configuration } from '../types'; | ||
|
||
export const useNeoVersionCheck = (configuration?: Partial<Configuration>) => { | ||
useEffect(() => { | ||
const performVersionCheck = async () => { | ||
const info = await getVersionInfo(); | ||
if (info.isUpdateAvailable) { | ||
Alert.alert( | ||
configuration?.title ?? 'Update Available', | ||
configuration?.message ?? | ||
'Please update the app to have the best experience', | ||
[ | ||
{ | ||
text: 'Update', | ||
onPress: () => { | ||
startUpdate(); | ||
}, | ||
style: 'default', | ||
}, | ||
{ | ||
text: 'Next time', | ||
style: 'default', | ||
}, | ||
] | ||
); | ||
} | ||
}; | ||
performVersionCheck(); | ||
}, [configuration?.message, configuration?.title]); | ||
}; |
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
11 changes: 2 additions & 9 deletions
11
src/useNeoVersionCheck.ts → src/iOS/useNeoVersionCheck.ios.ts
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 @@ | ||
export { useNeoVersionCheck } from './Android/useNeoVersionCheck.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { useNeoVersionCheck } from './iOS/useNeoVersionCheck.ios'; |
This file was deleted.
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