amplify-js: I'm not getting push notifications from AWS Pinpoint in react native (android) project, onRegister method is never triggered
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
1.My Firebase project configured correctly, I was able to receive push notification from Firebase console 2. I enabled Push notifications in AWS Pinpoint console and added API key and Sender ID there 3. I did these commands in the project: npm install @aws-amplify/pushnotification --save react-native link @aws-amplify/pushnotification
4.Added configuration for analytics and push notifications in App.js
Amplify.configure({
Auth: {
region: 'xxx',
userPoolId: 'xxx',
userPoolWebClientId: 'xxx',
mandatorySignIn: true
},
API: {
endpoints: [{
name: "xxx",
endpoint: "xxxx",
custom_header: async () => ({ Authorization: await getAuthorizationToken() })
}]
},
Analytics: {
disabled: false,
AWSPinpoint: {
appId: 'xxxxxx',
region: 'us-east-1',
}
}
});
PushNotification.configure({
appId: 'xxxx',
region: 'us-east-1',
});
5.Added in componentDidMount in App.js method onRegister:
componentDidMount(){
PushNotification.onRegister((token) => {
console.log('in app registration', token);
});
}
After Sign In added this updateEndpoint method:
Analytics.updateEndpoint({
address: 'xxxx',
channelType: 'GCM',
userId: '1',
})
I was trying to create Test campaign in AWS Pinpoint console, but console didn’t see any devices and didn’t send anything to the phones. PushNotification.onRegister method is never triggered. I can’t get device token.
What I’m missing? How to make it work?
Expected behavior Device should receive push notification
Desktop (please complete the following information):
- OS: Android
Smartphone (please complete the following information):
- OS: Android
Additional context
I’m using AWS Cognito in the project already
Sample code Include additional sample code or a sample repository to help us reproduce the issue. (Be sure to remove any sensitive data)
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = ‘DEBUG’; in your app.
after adding Amplify.Logger.LOG_LEVEL = ‘DEBUG’; I see this messages:
AWSPinpointProvider - init clients
[DEBUG] 08:46.309 AWSPinpointProvider - no change for aws credentials, directly return from init
[DEBUG] 08:46.312 AWSPinpointProvider - record event with params
[DEBUG] 08:46.314 AWSPinpointProvider - pinpoint put events with params Object {
AWSPinpointProvider - record event success.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (1 by maintainers)
@saadq
Me too, it works in fireabase console, but not work in pinpoint.
document itself is very obsolete ( https://aws-amplify.github.io/docs/js/push-notifications ).
this does not work (firebase console).
this works (firebase console).
document is obsolete…, and implementation is blackhole…
so amplify team should make pushnotification’s up to date documents and examples, that works well.
@1pocketaces1 it works like a charm both in Android and IOS, well, as far as I remember it’s free for mobile, I think they charge only for web push notifications and extra features.
I’ve been having the same issue. I’m thinking about switching to OneSignal too; glad I found this post
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I did actually try passing a hardcoded device token to the
addressofupdateEndpoint, but it didn’t seem to resolve the issue 😕To answer your question, I was actually unable to get the
onRegistercall to run either. I just looked at the logs in Android Studio Logcat to get the device token that I used for both Firebase/Pinpoint.I did however see this issue which seems related, going to look into that.