Push Notification
Pesan dari server yang muncul di device user meski aplikasi tidak dibuka.
Push notification adalah mekanisme server mengirim pesan ke device user — untuk re-engagement, alert, atau update. Arsitektur: Server Anda → Expo Push Service → APNs (Apple/iOS) atau FCM (Google/Android) → Device. Token perangkat unik (Expo push token) didapatkan saat user pertama kali membuka app dan menyetujui notifikasi. Token dikirim ke backend untuk disimpan. Payload notifikasi berisi title, body, data (untuk navigasi), sound, badge. Handler: saat app foreground (listener), background (OS tampilkan), killed (OS tampilkan + buka app). Ekspo menyederhanakan ini dengan satu API untuk kedua platform. Rich notification mendukung gambar, action buttons, dan inline reply.
Contoh Kode
import * as Notifications from "expo-notifications";
const token = (await Notifications.getExpoPushTokenAsync()).data;
await sendTokenToServer(token);
Notifications.addNotificationResponseReceivedListener(response => {
const { screen, id } = response.notification.request.content.data;
navigation.navigate(screen, { id });
});