React-native-onesignal: 3.2.10: RNOneSignal.didSetNotificationOpenedHandler is not a function

Created on 7 Dec 2018  ·  30Comments  ·  Source: OneSignal/react-native-onesignal

Description:
RNOneSignal.didSetNotificationOpenedHandler is not a function

(your description here)

Environment

  1. OneSignal React-Native SDK: 2.9.4
  2. Added via Cocoapods
  3. [email protected]
  4. [email protected]

(recently updated to [email protected] from [email protected]: 3.2.8 worked fine)

Steps to Reproduce Issue:

  1. Install the OneSignal SDK using npm into your project
  2. Initialize the SDK in the iOS AppDelegate
  3. This does not result in the error mentioned in the description:
constructor(props: IPushNotifHandlerProps) {
    super(props);

    OneSignal.init(ONESIGNAL_ID, { kOSSettingsKeyAutoPrompt: false });

    this.addListeners();
  }

  componentWillUnmount() {
    this.removeListeners();
  }

  addListeners = (): void => {
    OneSignal.addEventListener("received", this.onReceived);
    // OneSignal.addEventListener("opened", this.onOpened);
    OneSignal.addEventListener("ids", this.onIds);
  };
  1. Uncommenting // OneSignal.addEventListener("opened", this.onOpened); DOES result in the error mentioned in the description.

Anything else:

Indeed, when logging out RNOnesignal in the project's index.js, didSetNotificationOpenedHandler is not one of the included methods:

image

Most helpful comment

@Nightsd01 thanks for the quick response! Does it have a requirement for react/react-native versioning? I'm running 3.2.12 with React 16.6 and RN 0.56., I've tried rolling backwards and have issues with that function all the way back to 3.2.6 (anything newer throws error).

Seems it's possibly something on my side then, just want to check and see if there was anything I'm obviously missing, thanks!

have you managed to solve this issue ?
i still get this error with 3.2.14

TypeError: RNOneSignal.didSetNotificationOpenedHandler is not a function

All 30 comments

Haha you beat me to it @wkoutre . The issue here is that, that function exists in the android module but not in the ios module.

@prog-24 Glad to see it's not an infamous byproduct of my morning fatigue :) I looked into the Obj-C code a bit and didn't find any trace of it there, though haven't diffed the Obj-C code of 3.2.8 and 3.2.10.

Apologies about that, I didn't sleep at a Holiday Inn Express last night and forgot to add a method stub to iOS. We've changed how the Opened/Received event handlers work in our Android implementation.

I've released an update (3.2.11) to fix the issue, thanks for reporting this so quickly!

Is this officially resolved? I seem to still have the issue with iOS when I have "OneSignal.addEventListener('opened', this.onOpened);"

I get "RNOneSignal.didSetNotificationOpenedHandler is not a function"

@tehwayne yes the issue is definitely resolved, please make sure you’re running the latest version (3.2.12)

@Nightsd01 thanks for the quick response! Does it have a requirement for react/react-native versioning? I'm running 3.2.12 with React 16.6 and RN 0.56., I've tried rolling backwards and have issues with that function all the way back to 3.2.6 (anything newer throws error).

Seems it's possibly something on my side then, just want to check and see if there was anything I'm obviously missing, thanks!

@Nightsd01 thanks for the quick response! Does it have a requirement for react/react-native versioning? I'm running 3.2.12 with React 16.6 and RN 0.56., I've tried rolling backwards and have issues with that function all the way back to 3.2.6 (anything newer throws error).

Seems it's possibly something on my side then, just want to check and see if there was anything I'm obviously missing, thanks!

have you managed to solve this issue ?
i still get this error with 3.2.14

TypeError: RNOneSignal.didSetNotificationOpenedHandler is not a function

Why this issue closed? I have same issue on Android with latest version 3.3.2 :(

I have same issue on Android with latest version 3.3.2 ```
````
TypeError: RNOneSignal.didSetNotificationOpenedHandler is not a function

This error is located at:
in App (at renderApplication.js:35)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:34)`


Same here, I have this issue in August 2019.

Same here,
RN version: 0.58.5
One Signal version: 3.3.2

Same issue
RN version: 0.60.5
One Signal version: 3.3.2

Same issue
RN version: 0.59.9
One Signal version: 3.3.2

Same issue
RN version: 0.60.0
One Signal version: 3.3.2

Same issue

same issue

Hi all,
Update to the latest version, do a clean restart and the error messages should go away.

I'm on the latest version and seem to be getting this every time I restart the packaging server (node start).

npm uninstall react-native-onesignal && npm install react-native-onesignal fixes it, but only if I run it while running the packaging server.

@rgomezp

Any update on the issue? I am running react-native-onesignal 3.6.0 and am still experiencing the same issue @rgomezp

I do not know if I fixed it right but I added the following lines to RCTOneSignalEventEmitter.m at line 360 and it works now @rgomezp

RCT_EXPORT_METHOD(didSetNotificationOpenedHandler) {
    //unimplemented in iOS
}

Hello,
That's strange it wasn't updating correctly. Glad to hear it works now

@rgomezp Will you be including this bug fix in the next release?

Hi, I'm having this issue on Android on the latest version, 3.6.2

Make sure to run pod update inside your ios directory

@rgomezp , issue is not just on iOS, I've created a new issue yesterday for this #936 . Thanks for having a look!

Hey @Rodrigo77777 ,
Try removing the node module and re-installing. It looks like the native SDKs are maybe being updated but somehow the index.js file in the module is not.

ps. Nice name!

I'm on the latest version and seem to be getting this every time I restart the packaging server (node start).

npm uninstall react-native-onesignal && npm install react-native-onesignal fixes it, but only if I run it while running the packaging server.

Still getting this error in the latest version (Android on Windows 10) and having to use this fix. Interestingly, it stopped on one project and popped up on a new one.

Crucially - it's occurring (and the fix does not work) when attempting to build for release on Android, meaning we can't go to production.

Any updates or fixes? @Nightsd01 @sidd65 @rgomezp

TypeError: c.didSetNotificationOpenedHandler is not a function. (In 'c.didSetNotificationOpenedHandler()', 'c.didSetNotificationOpenedHandler' is undefined)

Crucially - it's occurring (and the fix does not work) when attempting to build for release on Android, meaning we can't go to production.

Any updates or fixes? @Nightsd01 @sidd65 @rgomezp

TypeError: c.didSetNotificationOpenedHandler is not a function. (In 'c.didSetNotificationOpenedHandler()', 'c.didSetNotificationOpenedHandler' is undefined)

I've been having the same issue, did you find any solutions?

Was this page helpful?
0 / 5 - 0 ratings