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

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

Open
shubhanshubb opened this issue Jun 26, 2024 · 0 comments

Comments

@shubhanshubb
Copy link

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);
});
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant