Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOO-1148] add push notification permission request support for Android API level>=33 #73

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading