Skip to content

Commit 2df5f55

Browse files
committed
Add androidpush check
1 parent 21038cc commit 2df5f55

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

web/lib/service/android-push.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import {PushNotifications} from '@capacitor/push-notifications'
22
import {useEffect} from "react"
33
import {api} from "web/lib/api"
44
import {useUser} from "web/hooks/use-user"
5+
import {isAndroidWebView} from "web/lib/util/webview";
56

67
export default function AndroidPush() {
78
const user = useUser() // authenticated user
8-
const isWeb = typeof window !== 'undefined' && 'serviceWorker' in navigator
9+
const isAndroid = isAndroidWebView()
910
useEffect(() => {
10-
if (!user?.id || isWeb) return
11+
if (!user?.id || !isAndroid) return
1112
console.log('AndroidPush', user)
1213

1314
PushNotifications.requestPermissions().then(result => {
@@ -28,7 +29,7 @@ export default function AndroidPush() {
2829
PushNotifications.addListener('pushNotificationReceived', notif => {
2930
console.log('Push received', notif)
3031
})
31-
}, [user?.id, isWeb])
32+
}, [user?.id, isAndroid])
3233

3334
return null
3435
}

0 commit comments

Comments
 (0)