Skip to content

Commit

Permalink
[MOO-1148] add push notification permission request support for Andro…
Browse files Browse the repository at this point in the history
…id API level>=33 (#73)
  • Loading branch information
UrazAkgultan authored Oct 31, 2023
2 parents a2a2906 + dc4c2fe commit e5a9467
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/jsActions/mobile-resources-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed

- We updated the default presentation mode for both "Take Picture" and "Take Picture Advanced" to full screen.
- We have added push notification permission request support for Android API level>=33.

## [2.0.2] ColumnChart
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { NativeModules, Platform } from "react-native";
import { NativeModules, PermissionsAndroid, Platform } from "react-native";
import messaging from "@react-native-firebase/messaging";

// BEGIN EXTRA CODE
Expand All @@ -24,6 +24,16 @@ export async function RequestNotificationPermission(): Promise<boolean> {
return Promise.reject(new Error("Firebase module is not available in your app"));
}

if (Platform.OS === "android") {
return PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS)
.then(() => {
return true;
})
.catch(() => {
return false;
});
}

return messaging()
.requestPermission()
.then(() =>
Expand Down

0 comments on commit e5a9467

Please sign in to comment.