refactor: error message for notification subscription failure (#23304)

* improve: error message for notification subscription failure

* suggestions

* Update WebPushContext.tsx

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
This commit is contained in:
Bandhan Majumder
2025-08-31 08:12:44 +00:00
committed by GitHub
co-authored by Anik Dhabal Babu
parent d44a41c587
commit 4fb3639f71
@@ -71,7 +71,15 @@ export function WebPushProvider({ children }: ProviderProps) {
}
} catch (error) {
console.error("Failed to subscribe:", error);
showToast("Failed to enable notifications", "error");
if (
error instanceof DOMException &&
error.name === "InvalidAccessError" &&
error.message.includes("applicationServerKey")
) {
showToast("Please enable Google services for push messaging and try again", "error");
} else {
showToast("Failed to enable notifications", "error");
}
} finally {
setIsLoading(false);
}