GithubHelp home page GithubHelp logo

papb / expo-notifications-issue-test Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 2.0 22 KB

[expo-notifications] [android] [FCM] Listeners don't trigger. Notifications won't show if app is in foreground.

Home Page: https://github.com/expo/expo/issues/10133

License: MIT License

TypeScript 97.42% JavaScript 2.58%

expo-notifications-issue-test's Introduction

๐Ÿ› Bug Report

Summary of Issue

  • Listeners are not triggered

    • handleNotification within Notifications.setNotificationHandler is never called
    • Notifications.addNotificationReceivedListener is not triggered
    • Notifications.addNotificationsDroppedListener is not triggered
    • Notifications.addNotificationResponseReceivedListener is not triggered
  • If app is in foreground, push notifications do not arrive in my phone at all (otherwise they arrive normally)

  • It is a standalone app (.apk), built with Turtle CLI in CI, running on a real device, using FCM.

Environment - output of expo diagnostics & the platform(s) you're targeting

  • Result of expo diagnostics directly from CI:
  Expo CLI 3.27.4 environment info:
    System:
      OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
      Shell: 4.4.20 - /bin/bash
    Binaries:
      Node: 12.18.3 - /opt/hostedtoolcache/node/12.18.3/x64/bin/node
      Yarn: 1.22.5 - /usr/bin/yarn
      npm: 6.14.6 - /opt/hostedtoolcache/node/12.18.3/x64/bin/npm
    SDKs:
      Android SDK:
        API Levels: 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
        Build Tools: 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2
        Android NDK: 21.3.6528147
    npmPackages:
      expo: ~38.0.8 => 38.0.10 
      react: ~16.11.0 => 16.11.0 
      react-dom: ~16.11.0 => 16.11.0 
      react-native: https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz => 0.62.2 
      react-native-web: ~0.11.7 => 0.11.7 
    npmGlobalPackages:
      expo-cli: 3.27.4
    Expo Workflow: managed
  • Platform I'm targeting: Android

Reproducible Demo

I carefully created a minimal repository to show the issue:

https://github.com/papb/expo-notifications-issue-test

I think it is easy to understand, but I will be happy to answer any question about it.

Steps to Reproduce

1. Create a free Firebase project in Google, no need to activate Analytics for it

2. Add an Android app to it, as follows:

image

3. Save the google-services.json file you will get in the above step

4. Fork my example repository: https://github.com/papb/expo-notifications-issue-test

5. You will have to add a Secret to your fork:

  • Go to the repository settings;
  • Click Secrets
  • Click New Secret

6. The name of the Secret must be GOOGLE_SERVICES_JSON

7. The value of the Secret you obtain as follows:

  • Execute cat google-services.json | base64 to obtain a base64 representation of the json file.
  • The output from the command above will likely have multiple lines, you must delete all newlines manually and obtain a huge string without newlines
  • This huge single-line string will be the value of the Secret
  • To make sure you got the value correctly, check it by creating a temp.txt file with this huge string, and then run cat temp.txt | base64 -d - you should see in your console the contents of the original google-services.json file

8. Trigger the execution of the GitHub Action in your fork. The easiest way to do it is to make any edit to the readme file, this new commit you make will cause the GitHub Action to execute.

9. Once the action finishes (takes about 15 minutes), you will receive the built.apk:

image

10. Install this APK in your android device

11. Open it and click the Get FCM Token button, you will get a token

12. Go to your Firebase Console to send a test notification: https://console.firebase.google.com/project/expo-notifications-issue-test/notification/compose

13. As a sanity check, leave the app running in background on you app for now.

14. Compose a new test message and click Send test message:

image

15. It will ask you an FCM token, paste the token you obtained in step 11 above in your phone.

  • Note: the app has a Copy to Clipboard button for your convenience

16. Observe that after a few seconds you will see the notification in your android device, so far so good

17. Bring your app back into foreground in your device now

18. Send another test message as you did in step 14, observe that sadly absolutely nothing will happen at all

Expected Behavior vs Actual Behavior

  • First of all, the notification should at least appear in step 18 above
  • Also, one of the listeners defined inside useEffect in App.tsx should run, like this one, but they don't, no matter what I do
  • You can also try other interaction combinations, such as pressing the notification, dismissing the notification, nothing I do triggers any of the listeners

More precisely, the following lines of code should have been reached somehow:

Highlights (that I have no idea if matter or not)

expo-notifications-issue-test's People

Contributors

papb avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.