diff --git a/src/features/force-update-modal/force-update-modal.tsx b/src/features/force-update-modal/force-update-modal.tsx
index c3596a3e..22269587 100644
--- a/src/features/force-update-modal/force-update-modal.tsx
+++ b/src/features/force-update-modal/force-update-modal.tsx
@@ -1,23 +1,37 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { Button, Modal, Text, View } from 'react-native';
-import { translate } from 'localization/hooks';
+import { isUpdated, openStore } from 'hooks/force-update';
-import { isUpdated, openStore } from 'network/services/force-update';
+import { translate } from 'localization/hooks';
import { styles } from './force-update-modal.styles';
interface ForceUpdateProps {}
-const ForceUpdateModal = ({}: ForceUpdateProps) => (
-
-
-
- {translate('alert.update')}
-
+const ForceUpdateModal = ({}: ForceUpdateProps) => {
+ const [showModal, setShowModal] = useState(false);
+
+ useEffect(() => {
+ const checkAndUpdate = async () => {
+ const updated = await isUpdated();
+ if (!updated) {
+ setShowModal(true);
+ }
+ };
+ checkAndUpdate();
+ }, []);
+
+ return (
+
+
+
+ {translate('alert.update')}
+
+
-
-
-);
+
+ );
+};
export { ForceUpdateModal };
diff --git a/src/hooks/force-update.ts b/src/hooks/force-update.ts
new file mode 100644
index 00000000..d45e6041
--- /dev/null
+++ b/src/hooks/force-update.ts
@@ -0,0 +1,44 @@
+import { Linking, Platform } from 'react-native';
+import DeviceInfo from 'react-native-device-info';
+
+import remoteConfig from '@react-native-firebase/remote-config';
+
+export const isUpdated = async (): Promise => {
+ remoteConfig().setDefaults({
+ minimum_version: '',
+ });
+
+ const fetchedRemotely = await remoteConfig().fetchAndActivate();
+
+ if (fetchedRemotely) {
+ const remoteVersion = remoteConfig().getValue('').asString();
+ const localVersion = DeviceInfo.getVersion();
+ return compareVersions(localVersion, remoteVersion);
+ }
+ return true;
+};
+
+export const openStore = () => {
+ Platform.select({
+ ios: Linking.openURL(''),
+ android: Linking.openURL(''),
+ });
+};
+
+function compareVersions(local: string, remote: string): boolean {
+ const localVersion = local.split('.').map(versionNumber => parseInt(versionNumber, 10));
+ const remoteVersion = remote.split('.').map(versionNumber => parseInt(versionNumber, 10));
+
+ for (let i = 0; i < Math.max(localVersion.length, remoteVersion.length); i++) {
+ const localVersionComponent = localVersion[i] || 0;
+ const remoteVersionComponent = remoteVersion[i] || 0;
+
+ if (localVersionComponent < remoteVersionComponent) {
+ return false;
+ } else if (localVersionComponent > remoteVersionComponent) {
+ return true;
+ }
+ }
+
+ return true;
+}
diff --git a/src/network/services/force-update.ts b/src/network/services/force-update.ts
deleted file mode 100644
index 1dc33a6c..00000000
--- a/src/network/services/force-update.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Linking, Platform } from 'react-native';
-import DeviceInfo from 'react-native-device-info';
-
-import remoteConfig from '@react-native-firebase/remote-config';
-
-export const isUpdated = (): boolean => {
- remoteConfig()
- .setDefaults({
- minimum_version: '',
- })
- .then(() => remoteConfig().fetchAndActivate())
- .then(fetchedRemotely => {
- if (fetchedRemotely) {
- const remoteVersion = remoteConfig().getValue('').asString();
- const localVersion = DeviceInfo.getVersion();
- return compareVersions(localVersion, remoteVersion);
- }
- });
- return true;
-};
-
-export const openStore = () => {
- if (Platform.OS === 'android') {
- Linking.openURL('');
- } else {
- Linking.openURL('');
- }
-};
-
-function compareVersions(local: string, remote: string): boolean {
- const localComponents = local.split('.').map(component => parseInt(component));
- const remoteComponents = remote.split('.').map(component => parseInt(component));
-
- for (let i = 0; i < Math.max(localComponents.length, remoteComponents.length); i++) {
- const localComponent = localComponents[i] || 0;
- const remoteComponent = remoteComponents[i] || 0;
-
- if (localComponent < remoteComponent) {
- return false;
- } else if (localComponent > remoteComponent) {
- return true;
- }
- }
-
- return true;
-}