import { registerPlugin } from '@capacitor/core'; import { isNativePlatform } from '../utils/capacitor'; // Bridge to the native NotificationPolicyPlugin (see // android/app/src/main/java/chat/vojo/app/NotificationPolicyPlugin.java). // "Do Not Disturb access" lets the incoming-call channel bypass DND / Bedtime so // calls ring through. Web and iOS get the no-op fallback below — this only exists // on Android. export interface NotificationPolicyPlugin { canBypassDnd(): Promise<{ value: boolean }>; openSettings(): Promise; } const NotificationPolicy = registerPlugin('NotificationPolicy', { web: { canBypassDnd: async () => ({ value: true }), openSettings: async () => undefined, }, }); export const canBypassDnd = async (): Promise => { if (!isNativePlatform()) return true; try { const { value } = await NotificationPolicy.canBypassDnd(); return value; } catch { // Plugin not yet available (older APK installed before it shipped). Fail // "allowed" so we don't nag — without the grant calls just don't ring through // DND, which the user can resolve from Settings themselves. return true; } }; export const openNotificationPolicySettings = async (): Promise => { if (!isNativePlatform()) return; await NotificationPolicy.openSettings(); };