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:
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user