ရိုးရိုးလေး ရှင်းပြမယ်
Push Notifications Basics ကို ရိုးရိုးလေးနားလည်မယ်
Push notification ရဲ့ high-level workflow — (1) App က permission တောင်း, (2) device unique 'push token' ရယူ, (3) push token ကို backend server ဆီ ပို့သိမ်း, (4) backend က event တစ်ခုခု ဖြစ်ချိန် (message ရောက်, order confirm) push token ကို သုံးပြီး Expo/FCM/APNs push service ကနေတဆင့် notification ပို့။ Local notification (device ကိုယ်တိုင် schedule) နဲ့ Remote/Push notification (server ကနေ trigger) ကို ခွဲခြားနားလည်ဖို့ အရေးကြီးပါတယ်။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
Push token ကို backend database ထဲ သိမ်းစရာ မလိုတယ်လို့ ထင်ခြင်း — remote push ပို့ဖို့ backend ကနေ token ကို သိထားရပါမည်
ဖြစ်လေ့ရှိတဲ့အမှား
Local vs Push notification ကို ရောနားလည်ပြီး backend architecture design ကို ရှုပ်ထွေးအောင်လုပ်ခြင်း
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Push Notifications Basics ကို permission, loading, empty, offline, timeout, cancellation, retry, app background/foreground နဲ့ stale-data behavior ပါသော lifecycle-aware flow အဖြစ်တည်ဆောက်ပါ။ Subscription, timer နဲ့ request cleanup ကိုမမေ့ပါနှင့်။
- JavaScript state
- Native component + layout
- Android / iOS UI
Push Notifications Basics ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
import * as Notifications from 'expo-notifications';
async function registerForPushNotifications() {
const { status } = await Notifications.requestPermissionsAsync();
if (status !== 'granted') return null;
const tokenData = await Notifications.getExpoPushTokenAsync();
return tokenData.data; // send this to your backend to store
}
// Local notification example (no backend needed)
await Notifications.scheduleNotificationAsync({
content: { title: 'Reminder', body: 'Practice React Native today!' },
trigger: { seconds: 60 },
});Push Notifications Basics ကို permission, loading, empty, offline, timeout, cancellation, retry, app background/foreground နဲ့ stale-data behavior ပါသော lifecycle-aware flow အဖြစ်တည်ဆောက်ပါ။ Subscription, timer နဲ့ request cleanup ကိုမမေ့ပါနှင့်။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- JavaScript state
import * as Notifications from 'expo-notifications';Push notification ရဲ့ high-level workflow — (1) App က permission တောင်း, (2) device unique 'push token' ရယူ, (3) push token ကို backend server ဆီ ပို့သိမ်း, (4) backend က event တစ်ခုခု ဖြစ်ချိန် (message ရောက်, order confirm) push token ကို သုံးပြီး Expo/FCM/APNs push service ကနေတဆင့် notification ပို့။ Local notification (device ကိုယ်တိုင် schedule) နဲ့ Remote/Push notification (server ကနေ trigger) ကို ခွဲခြားနားလည်ဖို့ အရေးကြီးပါတယ်။
- Native component + layout
}Push Notifications Basics ကို permission, loading, empty, offline, timeout, cancellation, retry, app background/foreground နဲ့ stale-data behavior ပါသော lifecycle-aware flow အဖြစ်တည်ဆောက်ပါ။ Subscription, timer နဲ့ request cleanup ကိုမမေ့ပါနှင့်။
- Android / iOS UI
});Push Notifications Basics example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
- JavaScript state
- Native component + layout
- Android / iOS UI
Success
Push Notifications Basics ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
Failure
Push token ကို backend database ထဲ သိမ်းစရာ မလိုတယ်လို့ ထင်ခြင်း — remote push ပို့ဖို့ backend ကနေ token ကို သိထားရပါမည်
ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
Push notification ရဲ့ high-level workflow — (1) App က permission တောင်း, (2) device unique 'push token' ရယူ, (3) push token ကို backend server ဆီ ပို့သိမ်း, (4) backend က event တစ်ခုခု ဖြစ်ချိန် (message ရောက်, order confirm) push token ကို သုံးပြီး Expo/FCM/APNs push service ကနေတဆင့် notification ပို့။ Local notification (device ကိုယ်တိုင် schedule) နဲ့ Remote/Push notification (server ကနေ trigger) ကို ခွဲခြားနားလည်ဖို့ အရေးကြီးပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
expo-notifications ကို install ပြီး Notifications.requestPermissionsAsync() ခေါ်ရင် permission dialog ပေါ်ပြီး, granted ရင် Notifications.getExpoPushTokenAsync() ကနေ unique token တစ်ခု ရပါတယ် — ဒီ token ကို backend database ထဲ user record နဲ့ တွဲသိမ်းထားရမှာပါ။ Local notification (ဥပမာ reminder) ကတော့ backend မလိုဘဲ Notifications.scheduleNotificationAsync() နဲ့ device ကိုယ်တိုင် schedule လုပ်လို့ရပါတယ်။
Code နမူနာ
import * as Notifications from 'expo-notifications';
async function registerForPushNotifications() {
const { status } = await Notifications.requestPermissionsAsync();
if (status !== 'granted') return null;
const tokenData = await Notifications.getExpoPushTokenAsync();
return tokenData.data; // send this to your backend to store
}
// Local notification example (no backend needed)
await Notifications.scheduleNotificationAsync({
content: { title: 'Reminder', body: 'Practice React Native today!' },
trigger: { seconds: 60 },
});Permission ရပြီးရင် push token string တစ်ခု ရမည်, local notification ကို ၆၀ စက္ကန့်အကြာ trigger ဖြစ်လာမည်။၅ မိနစ် စမ်းကြည့်
expo-notifications install ပြီး local notification (scheduleNotificationAsync) ကို ကိုယ်တိုင် schedule ကြည့်ပါ (Expo Go ပေါ်မှာ)။
သတိလေးတစ်ချက်
Push notification permission ကို app ဖွင့်ချက်ချင်း တောင်းရင် user တွေက deny ဖန်များပါတယ် — feature ကို တကယ်သုံးမယ့်အချိန် (ဥပမာ chat feature ပထမဆုံးသုံးချိန်) မှသာ contextually တောင်းတာက accept rate ပိုကောင်းပါတယ်။
Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Push Notifications Basics example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Push Notifications Basics example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
- Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
- Normal input နဲ့ edge case စမ်းပါ
- Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
import * as Notifications from 'expo-notifications';
async function registerForPushNotifications() {
const { status } = await Notifications.requestPermissionsAsync();
if (status !== 'granted') return null;
const tokenData = await Notifications.getExpoPushTokenAsync();
return tokenData.data; // send this to your backend to store
}
// Local notification example (no backend needed)
await Notifications.scheduleNotificationAsync({
content: { title: 'Reminder', body: 'Practice React Native today!' },
trigger: { seconds: 60 },
});ရလဒ်: Push Notifications Basics ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
Push Notifications Basics example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- JavaScript state → Native component + layout → Android / iOS UI
- Push Notifications Basics ကို permission, loading, empty, offline, timeout, cancellation, retry, app background/foreground နဲ့ stale-data behavior ပါသော lifecycle-aware flow အဖြစ်တည်ဆောက်ပါ။ Subscription, timer နဲ့ request cleanup ကိုမမေ့ပါနှင့်။
- Push token ကို backend database ထဲ သိမ်းစရာ မလိုတယ်လို့ ထင်ခြင်း — remote push ပို့ဖို့ backend ကနေ token ကို သိထားရပါမည်
- Push Notifications Basics example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
React Native Documentation — React Native