- google-services.json - utils/notifications.ts Fix: - app.config.js : tambah access googleServicesFile - app/_layout.tsx : tambah untuk push notifikasi - package.json: install install expo-notifications expo-device expo-constants ### No Issue
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { AuthProvider } from "@/context/AuthContext";
|
|
import AppRoot from "@/screens/RootLayout/AppRoot";
|
|
import { registerForPushNotificationsAsync } from "@/utils/notifications";
|
|
import { useEffect } from "react";
|
|
import "react-native-gesture-handler";
|
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function RootLayout() {
|
|
useEffect(() => {
|
|
// Jalankan sekali saat app pertama kali dibuka
|
|
registerForPushNotificationsAsync().then((token) => {
|
|
if (token) {
|
|
// TODO: Kirim token ke backend kamu
|
|
// Contoh:
|
|
// fetch('https://api.hipmibadung.id/save-token', {
|
|
// method: 'POST',
|
|
// headers: { 'Content-Type': 'application/json' },
|
|
// body: JSON.stringify({ token })
|
|
// });
|
|
}
|
|
});
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<SafeAreaProvider>
|
|
<AuthProvider>
|
|
<AppRoot />
|
|
</AuthProvider>
|
|
</SafeAreaProvider>
|
|
<Toast />
|
|
</>
|
|
);
|
|
}
|