question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android 12 not receving expo-notifications correctly

See original GitHub issue

Summary

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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
brentvatnecommented, Jun 22, 2022

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

2reactions
mmkhmkcommented, Jun 20, 2022

@txvnt We’re experiencing the same issue. Can confirm that after setting both compileSdkVersion and targetSdkVersion to 30 the notifications are working correctly.

@mmkhmk Have you tried above?

Yes, I tried it and it works with compileSdkVersion and targetSdkVersion 30. I didn’t find any no other solution so far.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo Notifications Not working properly on custom ...
When I schedule notification using scheduleReminderNotification I get a notification on the phone but when I use the expo push notification tool ...
Read more >
Stopped being able to receive notifications on iOS - Stack ...
Everything on Android is working properly, but on iOS I'm not able to receive notifications. I've checked and I have notifications allowed ...
Read more >
Android Notifications Not Showing Up? 10 Fixes You Can Try
The first step towards troubleshooting why no notifications are getting through to you is to ensure that it's not a temporary hiccup. To...
Read more >
Notifications Not Shown - Mobile Push
Android Settings App > Notifications > Your App you should see "Show notifications" enable and all categories underneath enabled. If you have a...
Read more >
expo-notifications-bux-fix v0.12.0 - npm.io
Then head over to android/app/src/main/AndroidManifest.xml and add a <meta-data> tag of android:name="expo.modules.notifications.default_notification_icon" ( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found