+
+
+
-
- Enable Notifications
-
-
-
- To use Web3Inbox and receive notifications from your subscribed apps, please enable push
- notifications.
-
-
+
Enable Notifications
+
+ To use Web3Inbox and receive notifications from your subscribed apps, please enable push
+ notifications.
+
{explicitlyDeniedPermissionForNotifications ? (
You have explicitly denied notification permissions. Please adjust in OS settings.
) : (
-
-
- You can always adjust your permissions in your OS settings.
-
-
+
+ You can always adjust your permissions in your OS settings.
+
diff --git a/src/constants/localStorage.ts b/src/constants/localStorage.ts
new file mode 100644
index 00000000..9b1af607
--- /dev/null
+++ b/src/constants/localStorage.ts
@@ -0,0 +1,3 @@
+export const localStorageKeys = {
+ notificationModalClosed: 'w3i:notification_modal_closed'
+}
diff --git a/src/utils/localStorage.ts b/src/utils/localStorage.ts
new file mode 100644
index 00000000..0ec945ce
--- /dev/null
+++ b/src/utils/localStorage.ts
@@ -0,0 +1,16 @@
+export class LocalStorage {
+ static get(key: string) {
+ if (typeof localStorage === 'undefined') {
+ return undefined
+ }
+
+ return localStorage.getItem(key)
+ }
+ static set(key: string, value: string) {
+ if (typeof localStorage === 'undefined') {
+ return undefined
+ }
+
+ return localStorage.setItem(key, value)
+ }
+}
diff --git a/src/utils/notifications.ts b/src/utils/notifications.ts
index ff22bec8..d541871d 100644
--- a/src/utils/notifications.ts
+++ b/src/utils/notifications.ts
@@ -1,7 +1,9 @@
-import { useEffect, useState } from 'react'
-
import { NotifyClient } from '@walletconnect/notify-client'
+import { localStorageKeys } from '@/constants/localStorage'
+import { LocalStorage } from '@/utils/localStorage'
+import { notificationPwaModalService } from '@/utils/store'
+
import { getFirebaseToken } from './firebase'
import { getDbEchoRegistrations, getDbSymkeyStore } from './idb'
@@ -61,6 +63,16 @@ export const setupSubscriptionsSymkeys = async (topicSymkeyEntries: [string, str
}
}
+export const closeNotificationModal = () => {
+ LocalStorage.set(localStorageKeys.notificationModalClosed, 'true')
+ notificationPwaModalService.closeModal()
+}
+
+export const checkIfNotificationModalClosed = () => {
+ const storageValue = LocalStorage.get(localStorageKeys.notificationModalClosed)
+ return storageValue === 'true'
+}
+
export const notificationsEnabledInBrowser = () => {
return 'Notification' in window
}
diff --git a/src/utils/pwa.ts b/src/utils/pwa.ts
index e0a9453a..1d2c8e7f 100644
--- a/src/utils/pwa.ts
+++ b/src/utils/pwa.ts
@@ -8,5 +8,5 @@ export const isInstalledOnHomescreen = () => {
export const isMobileBrowser = () => /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)
-export const isMobileButNotInstalledOnHomescreen = () =>
+export const isMobileButNotInstalledOnHomeScreen = () =>
isMobileBrowser() && !isInstalledOnHomescreen()