react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

In Old android devices such Android 10 version | Device Token not getting

Open shubhanshubb opened this issue 1 year ago • 0 comments

Bug

Environment info

react-native info output:

System: OS: macOS 14.5 CPU: (8) arm64 Apple M1 Memory: 114.28 MB / 8.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 22.2.0 path: /opt/homebrew/bin/node Yarn: version: 3.6.4 path: /opt/homebrew/bin/yarn npm: version: 10.7.0 path: /opt/homebrew/bin/npm Watchman: version: 2024.05.06.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/shubhanshu/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 23.5 - iOS 17.5 - macOS 14.5 - tvOS 17.5 - visionOS 1.2 - watchOS 10.5 Android SDK: Not Found IDEs: Android Studio: 2022.3 AI-223.8836.35.2231.11090377 Xcode: version: 15.4/15F31d path: /usr/bin/xcodebuild Languages: Java: version: 17.0.8.1 path: /opt/homebrew/opt/openjdk@17/bin/javac Ruby: version: 2.7.4 path: /Users/shubhanshu/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.73.8 wanted: ^0.73.6 react-native-macos: Not Found npmGlobalPackages: "react-native": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false

Library version: x.x.x

Steps To Reproduce

...

Describe what you expected to happen:

  1. I am not getting fcm token in old android device such android 10 or below
  2. It's not asking for permission for Allow Notification Popup

Here is the code for Requesting permission in my project

const NotificationHandler = (authContext) => { const { notification, setNotificationData, UpdateNotification } = authContext; return new Promise(async (resolve, reject) => { requestUserPermission({ notification, setNotificationData, UpdateNotification, }) .then(() => { return resolve(); }) .catch((error) => { console.log("fcm token error", error); return resolve(error); }); }); }; const requestUserPermission = async (authContext) => { let authStatus;

if (Platform.OS === "android") { return PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS ) .then((granted) => { if (granted === PermissionsAndroid.RESULTS.GRANTED) { authStatus = messaging.AuthorizationStatus.AUTHORIZED; } else { authStatus = messaging.AuthorizationStatus.DENIED; } }) .catch((err) => { console.log(err); authStatus = messaging.AuthorizationStatus.DENIED; }) .then(() => { return handleAuthorization(authStatus, authContext); }); } else { return messaging() .requestPermission() .then((status) => { authStatus = status; return handleAuthorization(status, authContext); }); } };

shubhanshubb avatar Jun 26 '24 11:06 shubhanshubb