Hi Guys,
I literally followed all the steps detailed in this guide -> https://aws.github.io/aws-amplify/media/push_notifications_setup#configure-your-app
However, when I try to include the push notifications in my React native project I get the following error. Not sure what I am doing wrong, I have done react-native link, uninstalled, re-linked, installed the amplify lib as a project dependency.

Still same error :(
Please see my package.json dependencies below
"dependencies": {
"aws-amplify": "^0.3.3",
"aws-amplify-react-native": "^0.2.9",
"moment": "^2.22.1",
"moment-timezone": "^0.5.16",
"prop-types": "^15.6.1",
"react": "16.3.1",
"react-native": "0.55.3",
"react-native-elements": "^0.19.1",
"react-native-vector-icons": "^4.6.0",
"react-navigation": "^1.5.11"
},
Can you make sure the push notification package is correctly linked into your app? You can check android/app/src/main/.../MainApplication.java to see if it is under getPackages()
@powerful23 thanks for the reply. I had a look in the android/app/src/main/.../MainApplication.java file the only packages imported are React native packages.
However when I run react native link it is always successful. I am guessing there is a bit of an issue with the linking process
Is there a way to manually add the package?
@oluomoniyi
android/settings.gradle like:rootProject.name = 'pushnotificationdemo'
include ':aws-amplify-react-native'
project(':aws-amplify-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/aws-amplify-react-native/android')
include ':app'
android/app/build.gradle:dependencies {
compile project(':aws-amplify-react-native')
// ....
}
android/app/main/..../MainApplication.java:@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNPushNotificationPackage()
);
}
Also there was some changes merged in the doc yesterday so please check that again.
Hi guys!
Im having the same issue as @oluomoniyi in an _almost_ bare project
Already tried @powerful23 suggestion but getting the same error.
Any ideas?
@powerful23 followed the steps you suggested and like @nachocifu still getting the error.
I think the root cause of this issue is that the aws-amplify-react-native module is not correctly linked into your project. You may try out a new blank project and follow the docs step by step and if it works, check out the android folder to see how it links the module.
I think I got it probably an obvious one @nachocifu @powerful23 but after you add the package to MainApplication.java you need to run the react-native run-android command (not npm start) to rebuild and reinstall the app on the emulator.
Quick way to test if you actually have access to push notifications in your react native project.
import { NativeModules} from 'react-native';
console.log("Should return RNPushNotification method", NativeModules.RNPushNotification);
Another thing to note before adding the below in your, android/app/main/..../MainApplication.java: make sure your import import com.amazonaws.amplify.pushnotification.RNPushNotificationPackage; at the top of the file.
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNPushNotificationPackage()
);
}
Most helpful comment
@oluomoniyi
android/settings.gradlelike:android/app/build.gradle:android/app/main/..../MainApplication.java:Also there was some changes merged in the doc yesterday so please check that again.