File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Device } from '@capacitor/device' ;
2+ import { PushNotifications } from '@capacitor/push-notifications' ;
3+ import { PermissionState } from '@capacitor/core' ;
4+
5+ export async function checkPermissions ( ) : Promise < CheckPermissionsResult > {
6+ const { platform } = await Device . getInfo ( ) ;
7+ let permissionState : CheckPermissionsResult [ 'permissionState' ] ;
8+ if ( platform === 'web' ) {
9+ permissionState = Notification . permission ;
10+ } else {
11+ let permissionsStatus = await PushNotifications . checkPermissions ( ) ;
12+ permissionState = permissionsStatus . receive ;
13+ }
14+
15+ return { permissionState}
16+ }
17+
18+ export interface CheckPermissionsResult {
19+ permissionState : NotificationPermission | PermissionState ;
20+ }
You can’t perform that action at this time.
0 commit comments