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 <[email protected]>
This commit is contained in:
1 parent
d44a41c587
commit
4fb3639f71
1 file changed
+9
-1
@@ -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