Android 12 not receving expo-notifications correctly
See original GitHub issueSummary
Upon sending notifications to an app using android SDK 31 the notifications never appear on the mobile phone.
The Notifications.addNotificationReceivedListener
is still called, but notification is never shown in the UI.
Also the Notifications.scheduleNotificationAsync
results in Error: Failed to schedule notification.
This is to my knowledge only happening on android 12.
Downgrading to SDK 30 makes notification work as expected again.
Tested with Poco F3, MIUI Global 13.0.3
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
bare
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
44.0.6
Environment
expo-env-info 1.0.2 environment info: System: OS: Linux 5.15 Manjaro Linux Shell: 5.8 - /usr/bin/zsh Binaries: Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node Yarn: 1.22.17 - /usr/bin/yarn npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm SDKs: Android SDK: API Levels: 29, 30, 31 Build Tools: 28.0.3, 29.0.2, 30.0.3 System Images: android-30 | Google APIs Intel x86 Atom npmPackages: expo: ~44.0.0 => 44.0.6 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 Expo Workflow: bare
Reproducible demo
Setting up a new bare workflow with
expo init test-notifications
expo eject
Installing / Setting up expo notifications
expo install expo-notifications
And following: https://docs.expo.dev/guides/setup-native-firebase/#bare-workflow-setup
Inserting the example from https://docs.expo.dev/versions/latest/sdk/notifications/ in App.js
Upgrading android SDK in root build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
}
...
}
And adding android:exported="true"
to AndroidManifest.xml under .MainActivity
, activity tag.
Now the issue can be reproduced by either pressing the schedule notification button or sending a notification to the push token, for example through the expo push notification tool.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:14 (1 by maintainers)
if you are using android sdk 30, you should use expo sdk 44. if you are using android sdk 31, you should use expo sdk 45. https://blog.expo.dev/expo-sdk-45-f4e332954a68
Yes, I tried it and it works with compileSdkVersion and targetSdkVersion 30. I didn’t find any no other solution so far.