I'm using Notifee 7.6.1 with RN 0.69.8.
Notifications are showing in iOS release builds and Android debug builds, but in Android release builds no notifications are showing.
Things I've already tried:
- Upgrading from React Native 0.68.X to 0.69.X in order to use Gradle 7.3.1
- Ensured SDK version is 33
- Double checked all permissions (
authorizationStatus and android.alarm are both enabled).
build.gradle:
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
buildTypes:
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
Implementation is here. I can see the Alert with the scheduled notification Date
const CHANNEL_ID = 'default';
const PushNotifications = () => {
const isLocalAuthenticated = useAppSelector(selectIsLocalAuthenticated);
const notificationsEnabled = useAppSelector(selectNotificationsEnabled);
const notificationsTime = useAppSelector(selectNotificationsTime);
const dispatch = useAppDispatch();
const createChannel = async () => {
await Notifications.createChannel({
id: CHANNEL_ID,
name: 'Reminder notifications',
importance: AndroidImportance.HIGH,
});
};
// Always create the channel when starting the app
useEffect(() => {
createChannel();
}, []);
// React to dependant variables and schedule notifications
useEffect(() => {
const scheduleNotifications = async () => {
await Notifications.cancelAllNotifications();
const trigger: TimestampTrigger = {
type: TriggerType.TIMESTAMP,
timestamp: Date.now() + 1000 * 60 * 2, // fire in 2 minutes
repeatFrequency: RepeatFrequency.WEEKLY,
};
const result = await Notifications.createTriggerNotification(
{
title: 'Notification title',
body: 'Notification body',
android: {
channelId: CHANNEL_ID,
smallIcon: 'ic_notification', // Bell icon
color: '#53BBF3',
},
},
trigger,
);
Alert.alert(
'',
'Scheduled notification' +
new Date(Date.now() + 1000 * 60 * 2) +
result,
);
};
if (notificationsEnabled) {
scheduleNotifications();
} else {
Notifications.cancelAllNotifications();
}
}, [notificationsEnabled, notificationsTime]);
// Configure initial permissions and settings
useEffect(() => {
const setupNotifications = async () => {
const { authorizationStatus } = await Notifications.requestPermission();
const accepted = authorizationStatus === AuthorizationStatus.AUTHORIZED;
dispatch(setNotificationsEnabled(accepted));
};
if (isLocalAuthenticated) {
setupNotifications();
}
}, [isLocalAuthenticated, dispatch]);
return <></>;
};
export default PushNotifications;
I'm using Notifee 7.6.1 with RN 0.69.8.
Notifications are showing in iOS release builds and Android debug builds, but in Android release builds no notifications are showing.
Things I've already tried:
authorizationStatusandandroid.alarmare both enabled).build.gradle:
buildTypes:
Implementation is here. I can see the Alert with the scheduled notification Date