I can't setup react-native-notifications for RN 0.60.4.
"react-native-notifications": "2.0.3",
/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:66: error: constructor RNNotificationsPackage in class RNNotificationsPackage cannot be applied to given types;
new RNNotificationsPackage(),
^
required: Application
found: no arguments
reason: actual and formal argument lists differ in length
@iutin I'm not using 2.0.3 yet, but here's an example:
https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/1095/files#diff-f8d41900983db719bc86a33e7df27c98R55
I couldn't use auto linking, so I did it manually.
Running into the same issue, setting up from zero on:
"react-native": "0.60.4",
"react-native-notifications": "2.0.3",
I followed the installation docs.
My MainApplication.java has:
import com.wix.reactnativenotifications.RNNotificationsPackage;
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return Arrays.<ReactPackage>asList(
new RNLocalizePackage(),
new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), isDebug()),
new RNDeviceInfo(),
new RNNotificationsPackage(MainApplication.this)
);
}
And I'm always getting the same error as the OP running yarn android or using Android Studio:
Error: Command failed: ./gradlew app:installDevelopmentDebug -PreactNativeDevServerPort=8081
/Users/***********/*******/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:60: error: constructor RNNotificationsPackage in class RNNotificationsPackage cannot be applied to given types;
new RNNotificationsPackage()
^
required: Application
found: no arguments
reason: actual and formal argument lists differ in length
1 error
FAILURE: Build failed with an exception.
Notice that I'm passing the argument but it's not being recognized.
Any help would be appreciated.
@eduardopelitti You need to disable the autolinking by creating react-native.config.js in your root with:
module.exports = {
dependencies: {
'react-native-notifications': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
},
},
};
This way your manual linking will work. However I couldn't get it to to work with RN 0.60.4 due the Firebase error. Can you please check if you can get it to work with your fresh 0.60.4 setup?
@eduardopelitti Thank you, your solution worked.
FYI it is now functional with react-native 0.60.4 and react-native-notifications 1.1.21 on both iOS and Android using FCM (token are retrieved and notifications using the FCM Legacy HTTP API are functional)
@eduardopelitti You need to disable the autolinking by creating
react-native.config.jsin your root with:module.exports = { dependencies: { 'react-native-notifications': { platforms: { android: null, // disable Android platform, other platforms will still autolink if provided }, }, }, };This way your manual linking will work. However I couldn't get it to to work with RN
0.60.4due the Firebase error. Can you please check if you can get it to work with your fresh0.60.4setup?
Awesome @jaska120, it worked. Thank you for the help!
@Geoffrey-D Credits should go to Jaska120! I didn't do anything.
This way your manual linking will work. However I couldn't get it to to work with RN
0.60.4due the Firebase error. Can you please check if you can get it to work with your fresh0.60.4setup?
It appears to be working properly now, at least it registered the device token, upon calling:
NotificationsAndroid.setRegistrationTokenUpdateListener(deviceToken => {
console.warn('Push-notifications registered!', deviceToken)
})
from App.js.
But so far I haven't tried sending an actual notification. Would you like me to try anything specifically?
Now I'm running into a dead-end when setting up iOS.
Running build on XCode fails with an error:
:-1: Library not found for -lBase64
And on using react-native run-ios, I get:
/Users/********/********/ios/build/Moba/Build/Products/Debug-iphonesimulator/libRNNotifications.a(RNNotificationCenterListener.o)
ld: 40 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
same thing with -lBase64
duplicate symbols usually means you linked twice.
In this case, you may have linked manually and via cocoapods.
with -lBase64 I had to open the project using a folder one level higher.
with duplicate symbols I had to remove extra libraries from compilation list and only leave cocoa pods.
Affirmative, linked again manually and it worked. Something must have gone wrong during the process the first time.
@eduardopelitti I was referring to Firebase error so I can't make it work on Android only with local notifications without Firebase. Are you running it with push notifications or local notifications?
@eduardopelitti I was referring to Firebase error so I can't make it work on Android only with local notifications without Firebase. Are you running it with push notifications or local notifications?
I'm only using Push Notifications for this project
Be wary of v2.0.3. I had mad issues with Android.
After some hours of debugging, I ended up switching to the latest version, v2.0.6, which appears to be working just fine with RN 0.60.4 and React Native Navigation v3.2.0.
Perhaps the issues were related to my setup, but on Android I had an infinite loop on the Splash screen when opening the app from the Home screen in a physical device, which is gone after upgrading to latest version.
First run from react-native run-android was successful, but when closing the app and reopening from device, I had this loop issue.
So my validated stack is:
- RN v0.60.4
- RN Navigation v3.2.0
- RN Notifications v.2.0.6
Hope this helps someone in the near future.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
The issue has been closed for inactivity.
@iutin I'm not using 2.0.3 yet, but here's an example:
https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/1095/files#diff-f8d41900983db719bc86a33e7df27c98R55I couldn't use auto linking, so I did it manually.
do you have any workaround with v3 or v2? the @@eduardopelitti workaround also didn't work for me!
I've got this error:
error: cannot find symbol
packages.add(new RNNotificationsPackage(MainApplication.this));
on
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.2",
"react-native-notifications": "^2.1.3"
},
@eduardopelitti have you found any workaround, just like you I'm using react-native-navigation with react-native-notification but I have lot of issue. can share with me MainApplication.java file?
@jsina I confirm 2.1.3 works with Android if you need help, I can share mine. I have stuck to link the library on iOS.
You might find the information on following issue useful. #396
I am having this issue after trying all the solutions mentioned above but it still does not work, i am on
react-native: 0.60.6
react-native-notifications: 1.1.17
Anyone know how to solve this ?
error: constructor RNNotificationsPackage in class RNNotificationsPackage cannot be applied to given types; new RNNotificationsPackage(), ^ required: Application found: no arguments reason: actual and formal argument lists differ in length
@eduardopelitti You need to disable the autolinking by creating
react-native.config.jsin your root with:module.exports = { dependencies: { 'react-native-notifications': { platforms: { android: null, // disable Android platform, other platforms will still autolink if provided }, }, }, };This way your manual linking will work. However I couldn't get it to to work with RN
0.60.4due the Firebase error. Can you please check if you can get it to work with your fresh0.60.4setup?
Do I just create a file? It is not working for me.
@eduardopelitti You need to disable the autolinking by creating
react-native.config.jsin your root with:module.exports = { dependencies: { 'react-native-notifications': { platforms: { android: null, // disable Android platform, other platforms will still autolink if provided }, }, }, };This way your manual linking will work. However I couldn't get it to to work with RN
0.60.4due the Firebase error. Can you please check if you can get it to work with your fresh0.60.4setup?Do I just create a file? It is not working for me.
Yes, this is used to disable Autolinking for the library on a specific platform. Perhaps your issue is different than mine, I don't have any info on your setup or the steps you've taken.
cfr.: https://github.com/react-native-community/cli
I haven't tried anything else so far, my setup has been working ever since with the same conditions I described earlier, which I would hardly classify as "the eduardopelitti workaround" as said earlier 馃槀 I followed some advice here and manually linked the lib whilst disabling autolinking via the react-native-config.js file (an imperfect solution since autolinking should have worked).
Since installing this many new versions of RN have come up and I'm guessing new versions of this package as well so this solutions may be outdated by now.
@eduardopelitti Nevermind! I was actually getting a different error. The fix worked! Thanks!
Most helpful comment
@eduardopelitti You need to disable the autolinking by creating
react-native.config.jsin your root with:This way your manual linking will work. However I couldn't get it to to work with RN
0.60.4due the Firebase error. Can you please check if you can get it to work with your fresh0.60.4setup?