@@ -50,6 +50,7 @@ import { Database } from './Database/Database'
5050import { isLegacyIdentifier } from './Database/LegacyIdentifier'
5151import { LegacyKeyValueStore } from './Database/LegacyKeyValueStore'
5252import Keychain from './Keychain'
53+ import notifee , { AuthorizationStatus , Notification } from '@notifee/react-native'
5354
5455export type BiometricsType = 'Fingerprint' | 'Face ID' | 'Biometrics' | 'Touch ID'
5556
@@ -75,7 +76,40 @@ export class MobileDevice implements MobileDeviceInterface {
7576 private stateObserverService ?: AppStateObserverService ,
7677 private androidBackHandlerService ?: AndroidBackHandlerService ,
7778 private colorSchemeService ?: ColorSchemeObserverService ,
78- ) { }
79+ ) {
80+ this . initializeNotifications ( ) . catch ( console . error )
81+ }
82+
83+ async initializeNotifications ( ) {
84+ if ( Platform . OS !== 'android' ) {
85+ return
86+ }
87+
88+ await notifee . createChannel ( {
89+ id : 'files' ,
90+ name : 'File Upload/Download' ,
91+ } )
92+ }
93+
94+ async canDisplayNotifications ( ) : Promise < boolean > {
95+ const settings = await notifee . requestPermission ( )
96+
97+ return settings . authorizationStatus >= AuthorizationStatus . AUTHORIZED
98+ }
99+
100+ async displayNotification ( options : Notification ) : Promise < string > {
101+ return await notifee . displayNotification ( {
102+ ...options ,
103+ android : {
104+ ...options . android ,
105+ channelId : 'files' ,
106+ } ,
107+ } )
108+ }
109+
110+ async cancelNotification ( notificationId : string ) : Promise < void > {
111+ await notifee . cancelNotification ( notificationId )
112+ }
79113
80114 async removeRawStorageValuesForIdentifier ( identifier : string ) : Promise < void > {
81115 await this . removeRawStorageValue ( namespacedKey ( identifier , RawStorageKey . SnjsVersion ) )
0 commit comments