File tree Expand file tree Collapse file tree
packages/jsActions/mobile-resources-native/src/notifications Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55// - the code between BEGIN USER CODE and END USER CODE
66// - the code between BEGIN EXTRA CODE and END EXTRA CODE
77// Other code you write will be lost the next time you deploy the project.
8- import { NativeModules , Platform } from "react-native" ;
8+ import { NativeModules , PermissionsAndroid , Platform } from "react-native" ;
99import messaging from "@react-native-firebase/messaging" ;
1010
1111// BEGIN EXTRA CODE
@@ -24,6 +24,16 @@ export async function RequestNotificationPermission(): Promise<boolean> {
2424 return Promise . reject ( new Error ( "Firebase module is not available in your app" ) ) ;
2525 }
2626
27+ if ( Platform . OS === "android" ) {
28+ return PermissionsAndroid . request ( PermissionsAndroid . PERMISSIONS . POST_NOTIFICATIONS )
29+ . then ( ( ) => {
30+ return true ;
31+ } )
32+ . catch ( ( ) => {
33+ return false ;
34+ } ) ;
35+ }
36+
2737 return messaging ( )
2838 . requestPermission ( )
2939 . then ( ( ) =>
You can’t perform that action at this time.
0 commit comments