Skip to content

Commit

Permalink
feat: support expo updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Aug 17, 2024
1 parent dce1dd6 commit fce5336
Show file tree
Hide file tree
Showing 8 changed files with 690 additions and 158 deletions.
1 change: 1 addition & 0 deletions .easignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ dist/*
!dist/apple-app-site-association

# Below is why we need .easignore
# https://github.com/expo/eas-cli/issues/1253
# google-services.json
# GoogleService-Info.plist
47 changes: 46 additions & 1 deletion app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import {useEffect, useState} from 'react';
import type {ColorSchemeName} from 'react-native';
import {Platform, useColorScheme} from 'react-native';
import {GestureHandlerRootView, RectButton} from 'react-native-gesture-handler';
import {
checkForUpdateAsync,
fetchUpdateAsync,
reloadAsync,
useUpdates,
} from 'expo-updates';
import {dark, light} from '@dooboo-ui/theme';
import styled, {css} from '@emotion/native';
import * as Notifications from 'expo-notifications';
Expand Down Expand Up @@ -29,6 +35,7 @@ import CustomLoadingIndicator from '../src/components/uis/CustomLoadingIndicator
import {fetchUserProfile} from '../src/apis/profileQueries';
import {registerForPushNotificationsAsync} from '../src/utils/notifications';
import {fetchAddPushToken} from '../src/apis/pushTokenQueries';
import useAppState from '../src/hooks/useAppState';

SplashScreen.preventAutoHideAsync();

Expand Down Expand Up @@ -59,6 +66,44 @@ function App(): JSX.Element | null {
const {back, replace} = useRouter();
const [{authId}, setAuth] = useRecoilState(authRecoilState);
const [initialRouteName, setInitialRouteName] = useState<string>();
const [checkEasUpdate, setCheckEasUpdate] = useState(false);
const {isUpdateAvailable, isUpdatePending} = useUpdates();

useEffect(() => {
if (isUpdatePending) {
reloadAsync();
}
}, [isUpdatePending]);

useAppState((state) => {
if (state === 'active') {
/* check eas updates */
const checkUpdate = async (): Promise<void> => {
if (Platform.OS === 'web' || __DEV__) {
return;
}

await checkForUpdateAsync();

try {
if (isUpdateAvailable) {
setCheckEasUpdate(true);
await fetchUpdateAsync();
}
} catch (e) {
if (__DEV__) {
console.error(e);
}
} finally {
setCheckEasUpdate(false);
}
};

checkUpdate();

return;
}
});

useEffect(() => {
const {data} = supabase.auth.onAuthStateChange(async (evt, session) => {
Expand Down Expand Up @@ -185,7 +230,7 @@ function App(): JSX.Element | null {
}
}, [assetLoaded, authId]);

if (!initialRouteName) {
if (!initialRouteName || checkEasUpdate) {
return <CustomLoadingIndicator />;
}

Expand Down
Binary file removed assets/adaptive_icon.png
Binary file not shown.
Binary file modified bun.lockb
Binary file not shown.
11 changes: 0 additions & 11 deletions dist/apple-app-site-association

This file was deleted.

23 changes: 19 additions & 4 deletions eas.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
{
"cli": {
"version": ">= 3.8.1"
},
"build": {
"development": {
"channel": "development",
"developmentClient": true,
"distribution": "internal",
"android": {
"distribution": "internal",
"withoutCredentials": true
"buildType": "apk"
},
"ios": {
"simulator": true
}
},
"preview": {
"channel": "preview",
"extends": "production",
"distribution": "internal",
"android": {
"buildType": "apk"
}
},
"production": {
"env": {
"ENVIRONMENT": "production"
"channel": "production",
"cache": {
"disabled": true
}
}
},
"submit": {
"production": {}
}
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"build:web:post": "cp assets/favicon.png dist/",
"build:web": "expo export --platform web && bun build:web:post",
"test": "jest --runInBand",
"android:release": "dotenv -e .env -- expo run:android --variant release",
"ios:release": "dotenv -e .env -- expo run:ios --configuration Release",
"eas:dev:updates": "dotenv -e .env -- eas update --branch development",
"eas:preview:android": "dotenv -e .env.production -- eas build --profile preview --platform android",
"eas:prod:updates": "dotenv -e .env.production -- eas update --branch production",
Expand All @@ -23,9 +25,9 @@
"eas:dev:ios": "dotenv -e .env -- eas build --profile development --platform ios",
"eas:dev:android": "dotenv -e .env -- eas build --profile development --platform android",
"eas:prod:secrets": "eas secret:push --scope project --env-file .env.production",
"eas:prod:ios": "eas build --profile production --platform ios",
"eas:prod:ios": "dotenv -e .env.production -- eas build --profile production --platform ios",
"eas:prod:android": "dotenv -e .env.production -- eas build --profile production --platform android",
"eas:prod:android:local": "eas build --profile production --platform android --local",
"eas:prod:android:local": "dotenv -e .env.production -- eas build --profile production --platform android --local",
"eas:submit:ios": "dotenv -e .env.production -- eas submit --profile production --platform ios",
"eas:submit:android": "dotenv -e .env.production -- eas submit --profile production --platform android",
"generate:supabase": "bunx supabase gen types typescript --project-id \"dnwizkmicoxcnzlfeali\" --schema public > src/types/supabase.ts",
Expand Down Expand Up @@ -91,7 +93,7 @@
"react-native-reanimated-carousel": "^3.5.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-svg": "15.5.0",
"react-native-svg": "15.2.0",
"react-native-tab-view": "^3.5.2",
"react-native-url-polyfill": "^2.0.0",
"react-native-web": "~0.19.12",
Expand Down
Loading

0 comments on commit fce5336

Please sign in to comment.