Notification not showing on Android 13 and higher
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- android, javascript, react-native, typescript
- Domain
- mobile
Research direction
Start by checking the Android notification permission behavior for target SDK 33 and React Native 0.73, then trace how this library starts its background service and displays its notification. The issue includes a permission request example but names no source files or tests, and the cause is still uncertain. Done means establishing expected behavior on Android 13 and documenting or fixing it, with coverage for the chosen behavior.
Written by the indexing model from the issue text.
Description
A notification will be shown when the task is running, it is not possible to start the service without it. The notification will only be visible in Android.
this is no longer true for Android 13 and higher when using React Native 0.73 or higher (I think or maybe all versions)
Think it has to do with the target sdk bump.
For some reason the backround task is still running in background for me without a notification which I thought was required.
Though maybe it will get killed eventually because of this?
This is how I solved it but maybe this should be in docs? and maybe in implementation?
useEffect(() => {
const askForPermissionsAndStartBackgroundService = async () => {
const notificationsAllowed = await askForPostNotificationsPermission();
if (!notificationsAllowed) return;
await BackgroundService.start(
...config,
);
};
askForPermissionsAndStartBackgroundService();
}, []);
export async function askForPostNotificationsPermission(): Promise<boolean> {
if (Platform.OS !== 'android') return false;
if (Platform.Version < 33) return false; // Only request for Android versions 13 and above
try {
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, {
title: 'Notification Permission',
message: 'We need your permission to show you notifications',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
});
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('Permission Granted. You can now receive notifications.');
return true;
} else if (granted === PermissionsAndroid.RESULTS.DENIED) {
console.log('Permission Denied. Notification permission is required.');
} else if (granted === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) {
console.log('Permission Blocked. Notification permission has been blocked.');
Alert.alert('Notification has not been granted!', 'Please long press on app icon, select App Info, select Notifications and enable all notifications.');
}
} catch (e) {
console.warn('requestPostNotificationsPermission error', e);
}
return false;
}
- Dominant language
- Java
- Stars
- 941
- Forks
- 145
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rapsssito/react-native-background-actions
-
iOS CocoaPods build fails: Package.swift included in sources causes No such module 'PackageDescription'Possibly taken @dattm97 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 18/100
Rapsssito/react-native-background-actions#255 · 4 comments ·
-
enhancement help wanted
Difficulty 5/5 Over a week Newbie friendliness 20/100
Rapsssito/react-native-background-actions#249 · 16 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Rapsssito/react-native-background-actions#238 · 5 comments ·
All issues in Rapsssito/react-native-background-actions
Similar issues
-
bug verbose GC
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
IBM/javacore-analyser#677 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
liberation-data/fornax4j#302 ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
grimmory-tools/grimmory#3297 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SmartPack/PackageManager#186 ·
-
Area: Java feature request needs triage OS: Windows
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
actions/runner-images#15457 ·
Maintainers usually reply within 3 days