Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.2.10: RNOneSignal.didSetNotificationOpenedHandler is not a function #682

Closed
wkoutre opened this issue Dec 7, 2018 · 31 comments
Closed

Comments

@wkoutre
Copy link
Contributor

wkoutre commented Dec 7, 2018

Description:
RNOneSignal.didSetNotificationOpenedHandler is not a function

(your description here)

Environment

  1. OneSignal React-Native SDK: 2.9.4
  2. Added via Cocoapods
  3. react-native@0.57.5
  4. react-native-onesignal@3.2.10

(recently updated to react-native-onesignal@3.2.10 from react-native-onesignal@3.2.8: 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

@wkoutre wkoutre changed the title RNOneSignal.didSetNotificationOpenedHandler is not a function 3.2.10: RNOneSignal.didSetNotificationOpenedHandler is not a function Dec 7, 2018
@prog-24
Copy link

prog-24 commented Dec 7, 2018

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.

@wkoutre
Copy link
Contributor Author

wkoutre commented Dec 7, 2018

@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.

Nightsd01 added a commit that referenced this issue Dec 7, 2018
• A new bridge function (didSetNotificationOpenedHandler) was recently added to the Android native implementation of the SDK, but a corresponding iOS implementation was not added
• Fixes #682
@Nightsd01
Copy link
Contributor

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!

@tehwayne
Copy link

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"

@Nightsd01
Copy link
Contributor

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

@tehwayne
Copy link

tehwayne commented Dec 23, 2018

@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!

@sidd65
Copy link

sidd65 commented Jul 5, 2019

@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

@sinhpn92
Copy link

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

@lamaj411
Copy link

lamaj411 commented Aug 26, 2019

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)`
```
```

@feminefa
Copy link

Same here, I have this issue in August 2019.

@psloboda
Copy link

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

@basha777
Copy link

basha777 commented Sep 5, 2019

Same issue
RN version: 0.60.5
One Signal version: 3.3.2

@ponchautf
Copy link

Same issue
RN version: 0.59.9
One Signal version: 3.3.2

@julianoabrs
Copy link

Same issue
RN version: 0.60.0
One Signal version: 3.3.2

@janvdt
Copy link

janvdt commented Sep 12, 2019

Same issue

@williamswebworks
Copy link

same issue

@rgomezp
Copy link
Contributor

rgomezp commented Sep 16, 2019

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

@dancherb
Copy link

dancherb commented Oct 4, 2019

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.

@dancherb
Copy link

dancherb commented Oct 4, 2019

@rgomezp

@cdoshi
Copy link

cdoshi commented Dec 11, 2019

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

@cdoshi
Copy link

cdoshi commented Dec 11, 2019

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
}

@rgomezp
Copy link
Contributor

rgomezp commented Dec 11, 2019

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

@cdoshi
Copy link

cdoshi commented Dec 13, 2019

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

@Rodrigo77777
Copy link

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

@rgomezp
Copy link
Contributor

rgomezp commented Jan 15, 2020

Make sure to run pod update inside your ios directory

@Rodrigo77777
Copy link

Rodrigo77777 commented Jan 16, 2020

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

@rgomezp
Copy link
Contributor

rgomezp commented Jan 24, 2020

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!

@dancherb
Copy link

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.

@dancherb
Copy link

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)

@dell2duo
Copy link

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?

@rfns
Copy link

rfns commented Dec 16, 2022

This is for the ones still strugling on Android.

It seems like the mentioned versions only fixed it for iOS. In order to make it work for Android, I had to open the class RNOneSignal.java and add the following method:

   @ReactMethod
   public boolean didSetNotificationOpenedHandler() {
      return this.hasSetNotificationOpenedHandler;
   }

Don't forget that @ReactMethod annotation. That's how native methods are exposed to JS through the bridge.

Then I ran ./gradlew clean && gradlew assembleRelease and it worked.

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

No branches or pull requests