1import { ProxyNativeModule } from 'expo-modules-core'; 2 3export enum AndroidNotificationVisibility { 4 UNKNOWN = 0, 5 PUBLIC = 1, 6 PRIVATE = 2, 7 SECRET = 3, 8} 9 10export enum AndroidAudioContentType { 11 UNKNOWN = 0, 12 SPEECH = 1, 13 MUSIC = 2, 14 MOVIE = 3, 15 SONIFICATION = 4, 16} 17 18export enum AndroidImportance { 19 UNKNOWN = 0, 20 UNSPECIFIED = 1, 21 NONE = 2, 22 MIN = 3, 23 LOW = 4, 24 DEFAULT = 5, 25 /** @deprecated use `DEFAULT` instead */ 26 DEEFAULT = 5, 27 HIGH = 6, 28 MAX = 7, 29} 30 31export enum AndroidAudioUsage { 32 UNKNOWN = 0, 33 MEDIA = 1, 34 VOICE_COMMUNICATION = 2, 35 VOICE_COMMUNICATION_SIGNALLING = 3, 36 ALARM = 4, 37 NOTIFICATION = 5, 38 NOTIFICATION_RINGTONE = 6, 39 NOTIFICATION_COMMUNICATION_REQUEST = 7, 40 NOTIFICATION_COMMUNICATION_INSTANT = 8, 41 NOTIFICATION_COMMUNICATION_DELAYED = 9, 42 NOTIFICATION_EVENT = 10, 43 ASSISTANCE_ACCESSIBILITY = 11, 44 ASSISTANCE_NAVIGATION_GUIDANCE = 12, 45 ASSISTANCE_SONIFICATION = 13, 46 GAME = 14, 47} 48 49export interface AudioAttributes { 50 usage: AndroidAudioUsage; 51 contentType: AndroidAudioContentType; 52 flags: { 53 enforceAudibility: boolean; 54 requestHardwareAudioVideoSynchronization: boolean; 55 }; 56} 57 58// We're making inner flags required to set intentionally. 59// Not providing `true` for a flag makes it false, it doesn't make sense 60// to let it be left undefined. 61export type AudioAttributesInput = Partial<AudioAttributes>; 62 63export interface NotificationChannel { 64 id: string; 65 name: string | null; 66 importance: AndroidImportance; 67 bypassDnd: boolean; 68 description: string | null; 69 groupId?: string | null; 70 lightColor: string; 71 lockscreenVisibility: AndroidNotificationVisibility; 72 showBadge: boolean; 73 sound: 'default' | 'custom' | null; 74 audioAttributes: AudioAttributes; 75 vibrationPattern: number[] | null; 76 enableLights: boolean; 77 enableVibrate: boolean; 78} 79 80type RequiredBy<T, K extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, K>>; 81 82export type NotificationChannelInput = RequiredBy< 83 Omit< 84 NotificationChannel, 85 | 'id' // id is handled separately as a function argument 86 | 'audioAttributes' // need to make it AudioAttributesInput 87 | 'sound' 88 > & { audioAttributes?: AudioAttributesInput; sound?: string | null }, 89 'name' | 'importance' 90>; 91 92export interface NotificationChannelManager extends ProxyNativeModule { 93 getNotificationChannelsAsync?: () => Promise<NotificationChannel[] | null>; 94 getNotificationChannelAsync?: (channelId: string) => Promise<NotificationChannel | null>; 95 setNotificationChannelAsync?: ( 96 channelId: string, 97 channelConfiguration: NotificationChannelInput 98 ) => Promise<NotificationChannel | null>; 99 deleteNotificationChannelAsync?: (channelId: string) => Promise<void>; 100} 101