Improve handling of notification permission prompts
Update notification permission logic to differentiate between denied and dismissed states, and adjust locale messages accordingly. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 02bc349c-c9f1-47f4-967c-cfefeabde8bb Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/1WKAcHk Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -25,6 +25,7 @@ export type EnableReason =
|
||||
| "unsupported"
|
||||
| "unsupported_ios_safari"
|
||||
| "permission_denied"
|
||||
| "permission_dismissed"
|
||||
| "vapid_unavailable"
|
||||
| "subscribe_failed"
|
||||
| "server_rejected";
|
||||
@@ -148,7 +149,15 @@ export function usePushSubscription() {
|
||||
const perm = await Notification.requestPermission();
|
||||
if (perm !== "granted") {
|
||||
setStatus(perm === "denied" ? "denied" : "default");
|
||||
return { ok: false, reason: "permission_denied" };
|
||||
// Distinguish a hard "blocked" decision from the user just
|
||||
// dismissing the prompt without choosing — the messages need
|
||||
// to differ so we don't tell users to "unblock" when they
|
||||
// simply haven't decided yet.
|
||||
return {
|
||||
ok: false,
|
||||
reason:
|
||||
perm === "denied" ? "permission_denied" : "permission_dismissed",
|
||||
};
|
||||
}
|
||||
const reg = await getRegistration();
|
||||
if (!reg) return { ok: false, reason: "subscribe_failed" };
|
||||
|
||||
@@ -240,6 +240,7 @@
|
||||
"unsupported": "هذا المتصفح لا يدعم إشعارات شاشة القفل.",
|
||||
"unsupported_ios_safari": "على الآيفون/الآيباد، افتح Tx من أيقونة الشاشة الرئيسية أولاً (مشاركة → إضافة إلى الشاشة الرئيسية)، ثم فعّل الإشعارات من داخل التطبيق.",
|
||||
"permission_denied": "أذِن المتصفح للإشعارات مرفوض. افتح إعدادات الجهاز ← Tx وفعّل الإشعارات يدوياً.",
|
||||
"permission_dismissed": "لم يتم منح الإذن بعد. اضغط \"تفعيل\" مرة أخرى واختر \"السماح\" في نافذة المتصفح.",
|
||||
"vapid_unavailable": "تعذّر الاتصال بخادم الإشعارات. تأكّد من اتصالك ثم حاول مرة أخرى.",
|
||||
"subscribe_failed": "تعذّر تسجيل الجهاز لاستقبال الإشعارات. حاول مرة أخرى.",
|
||||
"server_rejected": "رفض الخادم تسجيل هذا الجهاز. حاول مرة أخرى أو أعد تسجيل الدخول."
|
||||
|
||||
@@ -246,6 +246,7 @@
|
||||
"unsupported": "This browser does not support lock-screen notifications.",
|
||||
"unsupported_ios_safari": "On iPhone/iPad, open Tx OS from its Home Screen icon first (Share → Add to Home Screen), then enable notifications from inside the app.",
|
||||
"permission_denied": "Notification permission is blocked. Open Settings → Tx OS on your device and enable notifications manually.",
|
||||
"permission_dismissed": "Permission wasn't granted yet. Tap \"Enable\" again and choose \"Allow\" in the browser prompt.",
|
||||
"vapid_unavailable": "Could not reach the notifications server. Check your connection and try again.",
|
||||
"subscribe_failed": "Could not register this device for notifications. Try again.",
|
||||
"server_rejected": "The server refused to register this device. Try again or sign in again."
|
||||
|
||||
Reference in New Issue
Block a user