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.

evaluating RNPushNotification.getInitialNotification is not an object

See original GitHub issue

Hi all,

I have installed React native push Notification and following the installation guide correctly but I faced this error: TypeError: null is not an object (evaluating 'RNPushNotification.getInitialNotification ').

import PushNotification from “react-native-push-notification”; import PushNotificationIOS from “@react-native-community/push-notification-ios”; import {Platform} from “react-native”; NotifService.js:

export default class NotifService {
  configure = () => {
    PushNotification.configure({
      // (optional) Called when Token is generated (iOS and Android)
      onRegister: function(token){
        console.log("[Notification Service] on register token:", token);
      },

      // (required) Called when a remote or local notification is opened or received
      onNotification: (notification) => {
        console.log("[Notification Service] onNotification:", notification);
    
        // process the notification
    
        // required on iOS only (see fetchCompletionHandler docs: https://github.com/react-native-community/react-native-push-notification-ios)
        notification.finish(PushNotificationIOS.FetchResult.NoData);
      },
      senderID: "----",

      permissions: {
          alert: true,
          badge: true,
          sound: true,
      },
      popInitialNotification: true,
      requestPermissions: true,
    });
  }
}

MyComponent.js:

componentDidMount() {
    this.localNotif = new NotifService();
    this.localNotif.configure();
  }

Any help/Ideas please?!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:29

github_iconTop GitHub Comments

14reactions
michaelVictoriaDevcommented, Oct 16, 2020

I solved my issue

npm install react-native-push-notification --save

13reactions
tarunkishore2303commented, Jan 3, 2021

Did you tried: #1335 (comment) ?

Yeah tried that too !

Edit : I reset the cache and deleted the build folder and now the error is gone but I am not getting the notification 😐

Edit 2. : I forgot to create a channel and after reading the changelog I did it properly and now it works perfectly and fine !

The possible fix for this issue is

reset the cache and delete the build folder and now the error will be gone

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-push-notification is undefined - Stack Overflow
Its all working on iOS but on android I get undefined is not an object(evaluating RNPushnotification.getInitialNotifications).
Read more >
cljsrn 2022-01-29 - Slack Archive
Could not evaluate form: (function (){try{return ... [TypeError: null is not an object (evaluating 'RNPushNotification.
Read more >
Discussion of React Native Push Notifications
getInitialNotification() , in order to get the initial notification on iOS. ... typeError null:null is not an object evaluating.this.
Read more >
react-native-push-notification - npm
If you do, notification handlers will not fire, because they are not loaded. ... Notification object example: ... RNPushNotification.
Read more >
PushNotificationIOS - React Native
getInitialNotification() ​ ... PushNotificationIOS.getInitialNotification();. This method returns a promise. If the app was launched by a push ...
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