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.

App does not open on notification click (should "pressAction" be a default without needing to specify it?)

See original GitHub issue

Apparent bug

It seems like the app does not open when clicking the notification body.

Environment

react-native: 0.66.4 @notifee/react-native: 4.0.1, device/api: Pixel_5_API_31

Reproduction steps

  1. npx react-native init repro
  2. npm i @notifee/react-native
  3. add android:exported="true" to AnroidManifest.xml
  4. update build.gradle with compileSdkVersion = 31 targetSdkVersion = 31
  5. add provided code of minimal example
  6. build app
  7. click button to display notification
  8. minimize app and click notification
  9. in my case, the notification disappears after a short moment but the app does not open

minimal example:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React from 'react';
import {View, Button} from 'react-native';

import notifee from '@notifee/react-native';

const App = () => {
  async function onDisplayNotification() {
    const channelId = await notifee.createChannel({
      id: 'default',
      name: 'Default Channel',
    });
    await notifee.displayNotification({
      title: 'title',
      body: 'body',
      android: {
        channelId,
        pressAction: {
          id: 'default',
        },
      },
    });
  }

  return (
    <View>
      <Button
        title="Display Notification"
        onPress={() => onDisplayNotification()}
      />
    </View>
  );
};

export default App;

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:39 (13 by maintainers)

github_iconTop GitHub Comments

20reactions
mikehardycommented, Jan 13, 2022

This works for me with flavors / applicationIdSuffice:


          await notifee.displayNotification({
            title: messageOptions.title,
            body: messageOptions.body,
            android: {
              channelId: BackgroundTaskService.CONNECTION_REQUEST_NOTIFICATION_CHANNEL_ID,
              smallIcon: 'drawable/minilogo_bw',
              pressAction: {
                id: 'default',
                launchActivity: 'default',
                launchActivityFlags: [AndroidLaunchActivityFlag.SINGLE_TOP],
              },
            },
          });
3reactions
helenafordcommented, Jan 26, 2022

Just updating here on status, the latest release v4.1.0 contains a fix for apps targeting API 31 and devices running Android 12.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interaction | Notifee
Press Action. Notifee does not provide any default interaction behaviour when a user presses a notification. The Android guidelines suggest a notification ...
Read more >
React-Native navigate after a notification press - Stack Overflow
We've been on this for a few hours now but I can't seem to get the deep linking working. Everything works just fine...
Read more >
Change notification and quick settings in Windows
You can change your notification settings at any time from the Settings app. Customize notifications. Select Start > Settings > System > Notifications....
Read more >
How to make PWAs re-engageable using Notifications and Push
Having the ability to cache the contents of an app to work offline ... Let's start with notifications — they can work without...
Read more >
Guide to React Native Push Notifications: How To Create and ...
App Open Events. A/B tests can be done to determine the efficacy of various notifications. For that you need to know which notification...
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