Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const config: ExpoConfig = {
icon: './assets/images/icon.png',
scheme: 'konect',
userInterfaceStyle: 'automatic',
newArchEnabled: true,
jsEngine: 'hermes',
ios: {
supportsTablet: true,
usesAppleSignIn: true,
Expand All @@ -38,9 +36,9 @@ const config: ExpoConfig = {
{
android: {
kotlinVersion: '2.0.21',
compileSdkVersion: 35,
compileSdkVersion: 36,
targetSdkVersion: 35,
buildToolsVersion: '35.0.0',
buildToolsVersion: '36.1.0',
},
},
],
Expand Down
35 changes: 17 additions & 18 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { useState, useEffect } from 'react';
import { AppState } from 'react-native';
import { getForceUpdate, appVersion, versionToNumber } from '../services/forceupdate';
import * as Notifications from 'expo-notifications';
import { registerForPushNotificationsAsync, shouldRecheckPermission } from '../services/notifications';
import { storePushToken, initPushTokenStore, getStoredToken } from '../utils/pushTokenStore';
import {
registerForPushNotificationsAsync,
shouldRecheckPermission,
} from '../services/notifications';
import { storePushToken, initPushTokenStore } from '../utils/pushTokenStore';
import { getAccessToken } from '../services/nativeAuthStore';
import { registerPushToken } from '../services/pushTokenApi';

Expand All @@ -17,7 +20,6 @@ Notifications.setNotificationHandler({
}),
});


export default function RootLayout() {
const { replace } = useRouter();
const [isReady, setIsReady] = useState(false);
Expand All @@ -43,9 +45,7 @@ export default function RootLayout() {

const accessToken = await getAccessToken();
if (accessToken) {
registerPushToken(token).catch((e) =>
console.error('자동 푸시 토큰 등록 실패:', e)
);
registerPushToken(token).catch((e) => console.error('자동 푸시 토큰 등록 실패:', e));
}
} else {
permissionDenied = true;
Expand Down Expand Up @@ -75,20 +75,19 @@ export default function RootLayout() {
useEffect(() => {
if (!isReady) return;

const response = Notifications.getLastNotificationResponse();
if (response?.notification) {
const data = response.notification.request.content.data.path;
if (typeof data === 'string') {
replace(`/webview/${encodeURIComponent(data)}`);
const handleNotificationResponse = (
response: Notifications.NotificationResponse | null | undefined,
) => {
const path = response?.notification.request.content.data?.path;
if (typeof path === 'string') {
replace(`/webview/${encodeURIComponent(path)}`);
}
}
};

const responseListener = Notifications.addNotificationResponseReceivedListener((response) => {
const data = response.notification.request.content.data.path;
if (typeof data === 'string') {
replace(`/webview/${encodeURIComponent(data)}`);
}
});
handleNotificationResponse(Notifications.getLastNotificationResponse());

const responseListener =
Notifications.addNotificationResponseReceivedListener(handleNotificationResponse);

return () => {
responseListener.remove();
Expand Down
15 changes: 14 additions & 1 deletion app/webview/[path].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
import { Slot, useLocalSearchParams } from 'expo-router';
import { WebView, WebViewMessageEvent } from 'react-native-webview';
import { SafeAreaView } from 'react-native-safe-area-context';
import CookieManager from '@react-native-cookies/cookies';
import CookieManager from '@preeternal/react-native-cookie-manager';
import * as WebBrowser from 'expo-web-browser';
import { generateUserAgent } from '../../utils/userAgent';
import { appVersion } from '../../services/forceupdate';
import { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes';
import { webUrl } from '../../constants/constants';
import { getStoredToken } from '../../utils/pushTokenStore';
Expand All @@ -26,6 +27,16 @@ const ALLOWED_ORIGINS = [new URL(webUrl).origin];

const userAgent = generateUserAgent();

const injectedJavaScript = `
(function () {
const allowedOrigins = ${JSON.stringify(ALLOWED_ORIGINS)};
if (allowedOrigins.includes(window.location.origin)) {
window.APP_VERSION = ${JSON.stringify(appVersion ?? '0.0.0')};
}
})();
true;
`;

const handleOnShouldStartLoadWithRequest = ({ url }: ShouldStartLoadRequest) => {
if (/^https?:\/\//i.test(url)) return true;
if (url === 'about:blank') return false;
Expand Down Expand Up @@ -152,6 +163,8 @@ export default function Index() {
thirdPartyCookiesEnabled={true}
sharedCookiesEnabled={true}
userAgent={userAgent}
hideKeyboardAccessoryView={Platform.OS === 'ios'}
injectedJavaScript={injectedJavaScript}
onShouldStartLoadWithRequest={handleOnShouldStartLoadWithRequest}
setSupportMultipleWindows
onOpenWindow={(event) => {
Expand Down
Loading
Loading