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

RNOneSignal.configure is not a function after updating OneSignal to the latest version #844

Closed
Luckygirlllll opened this issue Sep 6, 2019 · 17 comments

Comments

@Luckygirlllll
Copy link

Luckygirlllll commented Sep 6, 2019

Description:
I updated React native OneSignal from 3.2.12 version to 3.3.2 version, after that I started getting error during app launch.

(your description here)

Environment

  1. react-native: 0.59.8, "react-native-onesignal": "^3.3.2",
  2. I updated OneSignal using npm

Steps to Reproduce Issue:

Anything else:

(crash stacktraces, as well as any other information here)

Here is my code:

import OneSignal from 'react-native-onesignal';

initialize() {
        OneSignal.init(config.oneSignalAppId, {kOSSettingsKeyAutoPrompt : false});
        OneSignal.inFocusDisplaying(0);

        OneSignal.addEventListener('received', this.onReceived);
        OneSignal.addEventListener('opened', this.onOpened);
        OneSignal.addEventListener('ids', this.onIds);

        OneSignal.configure();
    }

Here is the full error stack trace:

NOneSignal.configure is not a function. (In 'RNOneSignal.configure()', 'RNOneSignal.configure' is undefined)

  • node_modules/react-native-onesignal/index.js:97:12 in addEventListener
  • src/tracking/PushNotificationService.js:24:35 in initialize
  • src/App.js:37:4 in App
  • node_modules/react-proxy/modules/createClassProxy.js:98:23 in
  • node_modules/react-proxy/modules/createClassProxy.js:96:6 in instantiate
@OscarYuen
Copy link

OneSignal.configure() was depreciated at the previous version.
It would be called automatically.

@Luckygirlllll
Copy link
Author

Hm, weird, but on OneSignal React Native SDK setup guide it still says, that we need to use OneSignal.configure();

Screen Shot 2019-09-07 at 11 05 59

@Luckygirlllll
Copy link
Author

When I'm removing OneSignal.configure(); I'm still getting an error:

RNOneSignal.configure is not a function

WasOneSignal.addEventListener('ids', this.onIds)deprecated a as well?

@OscarYuen
Copy link

Hm, weird, but on OneSignal React Native SDK setup guide it still says, that we need to use OneSignal.configure();

Screen Shot 2019-09-07 at 11 05 59

I believe the documentation is outdated. At 3.3.1 version, the configure() method was depreciated and at 3.3.2 version it was removed.

I am not sure about the ids event. It requires some clarification from one-signal.

@OscarYuen
Copy link

OscarYuen commented Sep 7, 2019

@Luckygirlllll

Commit Link

As I know from 3.3.1, configure() method would be called automatically from ids event.
And I found this commit for 3.3.2 release. They changed configure() method name in native code.

I am not sure you need to run the pod update and pod install again after updating the onesign version in npm.

@Luckygirlllll
Copy link
Author

Luckygirlllll commented Sep 7, 2019

@OscarYuen it seems that in my case error throws OneSignal.addEventListener('ids', this.onIds);, if I comment it, app works without error, however, I need this listener, because I use it to get device pushToken /

@Luckygirlllll
Copy link
Author

I removed OneSignal.configure(); from my code and removed configure() from node_modules/react-native-onesignal/index.js and app started work normally after that!

@rgomezp
Copy link
Contributor

rgomezp commented Sep 11, 2019

I will make sure the docs get updated. Thanks for bringin this up. The configure method is indeed deprecated. You don't need to call this anymore to trigger the 'ids' event as this gets triggered automatically

@rgomezp
Copy link
Contributor

rgomezp commented Sep 12, 2019

The docs have been updated. Cheers

@rgomezp rgomezp closed this as completed Sep 12, 2019
@luutruong
Copy link

I have same issue. When I upgrade to 3.5.0 and have this:
RNOneSignal.configure is not a function

Code:

 OneSignal.init(oneSignalAppId, {
        kOSSettingsKeyAutoPrompt: true,
        kOSSettingsKeyInFocusDisplayOption: 0
    });

    OneSignal.addEventListener('received', onReceivedNotification);
    OneSignal.addEventListener('opened', onOpenedNotification);
    OneSignal.addEventListener('ids', onRegisteredIds);

I have just install from npm which steps am i missing?

@rgomezp
Copy link
Contributor

rgomezp commented Nov 8, 2019

@luutruong ,
You're definitely on an older version of the SDK. Make sure you updated correctly

@luutruong
Copy link

luutruong commented Nov 9, 2019

@rgomezp How do i check if my version are latest? I see the Pod output.

Installing OneSignal 2.11.2 (was 2.10.0 and source changed to `https://cdn.cocoapods.org/` from `trunk`)

Is that latest version?

@luutruong
Copy link

@rgomezp bump!

@rgomezp
Copy link
Contributor

rgomezp commented Nov 11, 2019

@luutruong ,
Yes, that's the latest iOS native version. But the issue is not on the native side, but rather on the Javascript side. You need to make sure you're using the latest React Native OneSignal SDK version.
Also, please include the entire stack trace, to get a better idea of what is going on

@luutruong
Copy link

@rgomezp Quite strange. Now it's work fine.

@rgomezp
Copy link
Contributor

rgomezp commented Nov 15, 2019

@luutruong ,
strange. good to hear though! cheers

@nateblog
Copy link

I had to go through I lot of process just to fix this "ids" issue.

  1. when you install the one signal package it is not linked automatically so I had to do it manually via pods:

pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal/react-native-onesignal.podspec'

then pod install

  1. after that I had to locate the OneSignalSDK inside "Pods/OneSignal/iOS_SDK/OneSignalSDK/Framework" folder.

  2. Drag "OneSignal.framework" in to my xcode

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

5 participants