למה Push Notifications ו-Deep Links חשובים עכשיו יותר מתמיד
65% מהמשתמשים שמקבלים push notification חוזרים לאפליקציה תוך שעה. בלי notification, הם פשוט לא חוזרים. אבל זה לא רק לשלוח הודעה: notification שמוביל למסך הביתי הריק, במקום ישירות למוצר שעניין את המשתמש, מאבד את ה-conversion לחלוטין. Deep links הם הגשר בין ה-notification לתוכן הנכון. והטכנולוגיה השתנתה: ב-2024 Google סגרה את FCM Legacy API, כל קוד שלא עודכן ל-FCM v1 פשוט הפסיק לעבוד. שיעור זה מלמד לבנות את שני המנגנונים נכון, עם Claude כ-debugging partner.
ארכיטקטורת Notifications, מה קורה מאחורי הקלעים
לפני שכותבים שורת קוד, חשוב להבין את הזרימה. ישנן שלוש שכבות:
- iOS: השרת שלכם → APNs (Apple Push Notification service) → מכשיר → אפליקציה. דורש Apple Developer certificate ו-provisioning profile.
- Android: השרת שלכם → FCM v1 (Firebase Cloud Messaging) → מכשיר → אפליקציה. דורש google-services.json ו-FCM v1 credentials, לא legacy, שנסגר ביוני 2024.
- Expo: Expo Push Service עוטף את שתיהן ומחזיר טוקן יחיד (ExponentPushToken). קל יותר, אבל מ-SDK 53 חייבים development build, Expo Go לא עובד יותר לצורך זה.
טעות נפוצה: מפתחים רבים גילו ב-2024 שה-notifications שלהם הפסיקו לעבוד בלי התראה. הסיבה: FCM legacy API נסגר. אם לא עברתם ל-FCM v1 credentials ב-EAS, שום notification Android לא יגיע.
Prompt לSetup מלא עם Expo Notifications
הפרומפט הבא מייצר setup end-to-end שמכסה את כל ה-edge cases:
Deep Links, Custom Scheme לעומת Universal Links
ישנם שני סוגי deep links, וחשוב לדעת מתי להשתמש בכל אחד:
| סוג | דוגמה | יתרון | חיסרון |
|---|---|---|---|
| Custom Scheme | myapp://product/123 | פשוט להגדיר, עובד גם offline | כל app יכול לregister אותו, אין security. אם האפליקציה לא מותקנת, כישלון. |
| Universal Links (iOS) | https://store.co.il/product/123 | מאומת בserver, נופל ל-Safari אם לא מותקן | דורש apple-app-site-association על ה-server, מחזיר 200 עם Content-Type: application/json בלי redirect |
| App Links (Android) | https://store.co.il/product/123 | זהה ל-Universal Links | דורש assetlinks.json ב-/.well-known/ |
הסטנדרט ב-2025: שמרו custom scheme כ-fallback, והשתמשו ב-Universal Links/App Links כברירת מחדל. אם חנות ישראלית של סטארטאפ ת"א רוצה שלקוח שקיבל SMS עם לינק יגיע ישירות לעמוד המוצר, Universal Link הוא הפתרון.
Prompt להגדרת Deep Links עם React Navigation
Claude מייצר את כל הקבצים הנדרשים בבקשה אחת:
Configure deep links for React Native with React Navigation v6. Schemes: - Custom scheme: myapp:// - Universal Links iOS: https://app.mystore.co.il (needs apple-app-site-association) - App Links Android: https://app.mystore.co.il (needs assetlinks.json) Paths: - /product/:productId → ProductDetailScreen - /order/:orderId → OrderTrackingScreen - /promo/:code → HomeScreen with promo modal - /chat/:userId → ChatScreen - / → HomeScreen Generate: 1. linking config for React Navigation 2. apple-app-site-association JSON 3. assetlinks.json for Android 4. Test commands: xcrun simctl and adb for verification 5. Cold start handler in App.tsx using Linking.getInitialURL()
Cold Start, הבאג שכולם נתקלים בו
כשמשתמש מקבל notification כשהאפליקציה סגורה לחלוטין, מה שנקרא "quit state", ה-addNotificationResponseReceivedListener לא מופעל. הפתרון:
// App.tsx, בתוך useEffect לפני שNavigation mount
useEffect(() => {
// Cold start: notification tap when app was quit
Notifications.getLastNotificationResponseAsync().then(response => {
if (response?.notification.request.content.data?.screen) {
// Queue navigation, navigation may not be ready yet
setTimeout(() => {
navigationRef.current?.navigate(
response.notification.request.content.data.screen
);
}, 300); // 300ms delay to ensure navigation is mounted
}
});
// Cold start: deep link when app was quit
Linking.getInitialURL().then(url => {
if (url) handleDeepLink(url);
});
}, []);שימו לב: ב-Android יש race condition ידוע, Linking.getInitialURL() יכולה לחזור null אם ה-JS thread עוד לא מוכן. ה-timeout של 300ms פותר זאת ברוב המקרים.
טעויות נפוצות
- אין Notification Channel ב-Android: מ-Android 8 (API 26) חובה. בלי channel, notification שקטה לא תוצג בכלל. צרו channel עם importance=HIGH לפני בקשת הרשאה.
- Token לא מתעדכן אחרי reinstall: Token משתנה. רשמו addPushTokenListener ועדכנו ב-backend מיד. backend שמחזיק token ישן לא יגיע למשתמש.
- Universal Links עם redirect: apple-app-site-association חייב להחזיר 200 ישיר עם Content-Type: application/json. כל redirect (301/302) שובר את Universal Links בשקט.
- FCM credentials ישנים: מי שלא עדכן ל-FCM v1 עד יוני 2024, Android notifications מפסיקות לעבוד. בדקו את ה-EAS credentials.
סיכום
- FCM legacy מת, עברו ל-FCM v1 credentials ב-EAS
- Expo SDK 53+: צריך development build לטסט notifications, לא Expo Go
- Universal Links מחייבים 200 ישיר + Content-Type: application/json, בלי redirect
- Cold start: getLastNotificationResponseAsync + getInitialURL ב-App.tsx עם 300ms timeout
- Notification Channel ב-Android הוא חובה, לא אופציה
- Claude עוזר לנפות bugs: תנו לו את error message המלא + platform + SDK version ותקבלו פתרון ממוקד
