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

Getting RNFBMessagingModule.getToken got 4 arguments, expected 2 error #5379

Closed
akshaykatale99 opened this issue Jun 1, 2021 · 13 comments
Closed
Labels
help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report

Comments

@akshaykatale99
Copy link

akshaykatale99 commented Jun 1, 2021

Getting RNFBMessagingModule.getToken got 4 arguments, expected 2 error while calling getToken method.

Here is my code:

import messaging from '@react-native-firebase/messaging';
.
.
.
useEffect(() => {
        
        messaging()
        .getToken()
        .then(token => {
            console.log(token);
            setfcmToken(token);
        });
    }, []);

I am using follwing verions:

"react-native": "~0.63.3"
"@react-native-firebase/app": "^12.0.0"
"@react-native-firebase/database": "^12.0.0"
"@react-native-firebase/messaging": "^12.0.0"

@akshaykatale99 akshaykatale99 added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels Jun 1, 2021
@mikehardy
Copy link
Collaborator

Please read the breaking changes list for the v12 release https://github.com/invertase/react-native-firebase/blob/master/CHANGELOG.md

Those APIs are just a little bit different now

Here is how to follow this module so you can safely move along with us as we bump versions: https://invertase.io/blog/react-native-firebase-versioning

@rdtf1230
Copy link

rdtf1230 commented Jun 14, 2021

@akshaykatale99 i was same with u
but when i cleared metro cache ( ex npm start -- --reset cache )
it works
I hope this helps

@mikehardy
Copy link
Collaborator

Even better! npx react-native-clean-project - when you run into really bizarre / unexpected problems that one will clean you right out, down to fixing corrupted cocoapods downloads even.

@linaia
Copy link

linaia commented Jul 2, 2021

Please reopen : also got this with the following configuration on Android only (OS version : 8/9/10/11)

"react-native": "0.63.4"
"@react-native-firebase/analytics": "11.5.0",
"@react-native-firebase/app": "11.5.0",
"@react-native-firebase/messaging": "11.5.0",

I had to downgrade to 11.5 due to incompatibility with 12.x on iOS. Trying to update on Android only to 12.x

@mikehardy
Copy link
Collaborator

@linaia there's no incompatibility with ios vs android - it works, it appears npx react-native-clean-project would probably help you, either way you may see in our e2e test suite that everything is up to date and working

@linaia
Copy link

linaia commented Jul 2, 2021

@mikehardy I detail here what was the problem with pod install in ios and why I had to rollback to 11.5.

[!] CocoaPods could not find compatible versions for pod "GoogleAppMeasurement":
  In Podfile:
    EXAdsAdMob (from `../node_modules/expo-ads-admob/ios`) was resolved to 10.0.4, which depends on
      Google-Mobile-Ads-SDK (= 7.69.0) was resolved to 7.69.0, which depends on
        GoogleAppMeasurement (~> 7.0)

    RNFBAnalytics (from `../node_modules/@react-native-firebase/analytics`) was resolved to 12.1.0, which depends on
      Firebase/Analytics (= 8.1.1) was resolved to 8.1.1, which depends on
        Firebase/Core (= 8.1.1) was resolved to 8.1.1, which depends on
          FirebaseAnalytics (~> 8.1.0) was resolved to 8.1.0, which depends on
            FirebaseAnalytics/AdIdSupport (= 8.1.0) was resolved to 8.1.0, which depends on
              GoogleAppMeasurement (= 8.1.0)

I've opened a ticket for expo-ads-admob : expo/expo#13300.
So I had to find which version of @react-native-firebase has GoogleAppMeasurement (~> 7.0) and it went back to 11.5, no more pod install problem. But now it's on android ...

@SaeedZhiany
Copy link
Contributor

@akshaykatale99

did you manage to resolve the problem? I just upgrade fro v11.5.0 to 12.9.3 and I got the error message. I read the changelog and it says that

Messaging.getToken/deleteToken: scoped token APIs removed from upstream APIs. Remove scopes from API calls. deleteToken() should work on iOS now.

what does it mean?

shouldn't we use the getToken on messaging anymore like below? how we should access it from this new version?

cc @mikehardy

messaging()
        .getToken()
        .then(token => {
            console.log(token);
            setfcmToken(token);
        });

thanks

@mikehardy
Copy link
Collaborator

Hi @SaeedZhiany it means what it says :-) but I can elaborate a little - you may still use getToken and deleteToken (the APIs exist, and they work fine), you just cannot used scoped tokens. In the little snippet you include, you are not using a scoped token so that's fine, your usage appears fine. If you have an argument mis-match perhaps you just need to clear out your project build caching so that javascript and native code are in sync, I typically recommend npx react-native-clean-project for that. I would not go to 12.9.3 though, we're on 14.2.1 now I think? Good luck!

@SaeedZhiany
Copy link
Contributor

SaeedZhiany commented Jan 2, 2022

Hi @SaeedZhiany it means what it says :-) but I can elaborate a little - you may still use getToken and deleteToken (the APIs exist, and they work fine), you just cannot used scoped tokens. In the little snippet you include, you are not using a scoped token so that's fine, your usage appears fine. If you have an argument mis-match perhaps you just need to clear out your project build caching so that javascript and native code are in sync, I typically recommend npx react-native-clean-project for that. I would not go to 12.9.3 though, we're on 14.2.1 now I think? Good luck!

Ah, I didn't know what scoped tokens are. Thanks for clarifying. I need to support the pre-Lolipop Android version so I have to stick with 12.x.x version. Thanks, BTW

@mikehardy
Copy link
Collaborator

@SaeedZhiany Note that the minSdkVersion should be 19 which is actually down to KitKat https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT I think I made a mistake and you can still go pre-lollipop if needed.

f60afe1 - documented as 19 but I put 21 in package.json. You might try changing node_modules/@react-native-firebase/app/package.json and setting minSdk to 19 (using patch-package to make it persistent) and it should build? The release notes indicate it should build https://firebase.google.com/support/release-notes/android#analytics_v20-0-0

If you test it and it works I can move it from 21 to 19, you can post a PR here and I can get that released really quickly

I do completely understand sometimes there are real reasons but even with a developing world userbase target, there were fewer than 1% active devices for me with SDK < 19

@SaeedZhiany
Copy link
Contributor

Note that the minSdkVersion should be 19 which is actually down to KitKat https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT I think I made a mistake and you can still go pre-lollipop if needed.

Yeah I know that. but my project minSdk is 16 😄

I do completely understand sometimes there are real reasons but even with a developing world userbase target, there were fewer than 1% active devices for me with SDK < 19

I completely agree, but my managers don't wanna upgrade yet and drop support for the old Android versions!

However I'll try what you said and will inform you if it's ok to downgrade minSdk to 19 to make RNFB compatible with more Android versions.

@SaeedZhiany
Copy link
Contributor

@mikehardy
I created the PR. please review it

#5984

@capsandoval01
Copy link

Captura de Pantalla 2022-08-16 a la(s) 12 54 47 a m

Hola,

Me sucedió lo mismo por 2 días busque la solución hasta que la conseguí. después de actualizar a la versión 0.6.0, tendrás problemas de cache , realiza la siguiente operación

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

sudo react-native run-android

Captura de Pantalla 2022-08-16 a la(s) 12 53 47 a m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report
Projects
None yet
Development

No branches or pull requests

6 participants