Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

"popInitialNotification" always return "undefined" #2057

Closed
anishtr4 opened this issue Jun 17, 2021 · 7 comments
Closed

"popInitialNotification" always return "undefined" #2057

anishtr4 opened this issue Jun 17, 2021 · 7 comments

Comments

@anishtr4
Copy link

anishtr4 commented Jun 17, 2021

Bug

popInitialNotification method always return 'undefined' for local notification. I have tried in both scenarios while the app in background and while the app is closed . Tried both localNotificationSchedule, localNotification methods.

Environment info

react-native info output:

System:
    OS: macOS 11.2
    CPU: (8) x64 Apple M1
    Memory: 86.55 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.12 - /usr/local/bin/npm
    Watchman: 4.9.0 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK: Not Found
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.62 => 0.62.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: x.x.x

Steps To Reproduce

  1. Initiate a local notification
  2. Local notification received while app is close
  3. Tap on the local notification received
  4. PushNotification.popInitialNotification event triggered but returned with 'undefined'.
    ...

Describe what you expected to happen:

1.PushNotification.popInitialNotification event should return with local notification details which user clicked.
2.

Reproducible sample code

@Dallas62
Copy link
Collaborator

Take time to search in issue history

@anishtr4
Copy link
Author

anishtr4 commented Jun 17, 2021

@Dallas62
Would you mind sharing issue link. I have tried few of fix form issues history none of them did’t work.

Note: Iam on IOS and my app is not in background app is closed/killed.

@Dallas62
Copy link
Collaborator

For Android you can look at: https://github.com/zo0r/react-native-push-notification/issues?q=is%3Aissue+splashscreen
and https://github.com/zo0r/react-native-push-notification#android-manual-installation

If your app has an @OverRide on onNewIntent in MainActivity.java ensure that function includes a super call on onNewIntent (if your MainActivity.java does not have an @OverRide for onNewIntent skip this):

    @Override
    public void onNewIntent(Intent intent) {
        ...
        super.onNewIntent(intent);
        ...
    }

For iOS:
There is your issue opened and this one: react-native-push-notification/ios#24

@anishtr4
Copy link
Author

@Dallas62 , Does this “popInitialNotification” method works for local notifications as well or just for remote notification??

@Dallas62
Copy link
Collaborator

It's working only from killed state, but yes for all kind of notifications

@garrettmaring
Copy link

@Dallas62 I've searched through lot of history and still struggling to handle, on iOS, notifications from a killed state.

I've seen a couple random things saying to disabled remote debugging and to build the product in release mode, strange that those would interfere with notifications but I did that.

Given my understanding of popInitialNotification, I thought things would just work out of the box. That is, onNotification would be called from a killed state. That isn't happening.

So, I see popInitialNotification to false and added my own handler inside the top-most component with a useEffect(() => { PN.popInitialNotification(handler) }, []. That also doesn't work.

I've tried some other things and started messing around with PNIOS.getInitialNotification with no luck. I don't want to use an iOS only handler anyway though.

From the history of this problem, where would you advise that I look to get notification handling from killed state working on iOS/Android?

@vr1Ravi
Copy link

vr1Ravi commented Jun 11, 2024

Hey @Dallas62, I am new to this package. what i understood is popInitialNotification method is for a situation when your app is killed and you tap on notification. I impleted the logic but the current behaviour is sometimes i am getting notification as an object in a callback but sometime undefined. Now when I am gettting an object, My app is open and i get the notification then killing the app and tapping on notification redirects to desired screen. Second case when app is already killed and notification came, in this case tapping on notification getting undefined and hence no redirection. Could you please help I've been stuck on this for like 5 days.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants