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
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);
});
}
AfterSign 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):
Smartphone (please complete the following information):
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.
I am having similar issues with my device not receiving push notifications. I have an ejected Expo app where I setup Push Notifications by following the docs. I also have the PushNotification setup code, but none of the methods seem to ever get called.
From Firebase, sending a test notification worked when I passed it my device token and I received the notification on my device.
From the Pinpoint console in the "Test messaging" section, I tried Push Notifications with both an endpoint id as well as a device token:

When I tried the endpoint id method by using my user's endpoint id, I got a message saying endpoints must have an address to target:

When I tried the device token method by using the same device token that I used within the Firebase console, it seemingly says it worked:

However, my device never actually received any notification, nor were any of the PushNotification event handlers called.
My setup code:
Analytics.configure({
AWSPinpoint: {
appId: '...',
region: 'us-east-1',
mandatorySignIn: false
}
})
// This is called after sign in
Analytics.updateEndpoint({
...
})
PushNotification.configure({
appId: '...'
})
PushNotification.onNotification(notification => {
console.log('in app notification', notification)
})
// get the registration token
PushNotification.onRegister(token => {
console.log('in app registration', token)
})
// get the notification data when notification is opened
PushNotification.onNotificationOpened(notification => {
console.log('the notification is opened', notification)
})
@saadq Could you get device token throughonRegistermethod? Or only thought Firebase console?
P.S: you need to add address field in updateEndpoint as far as I understood address should be a device token.
I did actually try passing a hardcoded device token to the address of updateEndpoint, but it didn't seem to resolve the issue :/
To answer your question, I was actually unable to get the onRegister call 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.
@saadq How did you find device token in Android studio, I see in LogCat onlyFCM message id:
Logging event (FE): notification_open(_no), Bundle[{firebase_event_origin(_o)=fcm, message_device_time(_ndt)=0, message_time(_nmt)=1555314333, message_id(_nmid)=5461448130273880619}]
@saadq I found token in Android studio logcat, however, when I'm trying to test it via AWS Pinpoint it says "Message sent. Successfully sent push message", but I don't receive any Push notification on my phone. :(
For anyone else who runs into this, just search for gcm registration token in the logs to find the device token.
But yeah @Luckygirlllll, I basically have the same issue. I get the successful message sent message but I don't actually get any notification to my device. :/
I can still reproduce this 1 month later, was it fixed?
@DubluDD no, I switched to OneSignal library instead.
And you managed to get it working on both ios/android?
@DubluDD yes, it works like a charm! :)
@Luckygirlllll great! Thanks :D
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.
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
@Luckygirlllll no major issues implementing OneSignal for both iOS and Android? How does the cost compare to Pinpoint?
@1pocketaces1 it works like a charm both in Android and IOS, well, as far as I remember it鈥檚 free for mobile, I think they charge only for web push notifications and extra features.
@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).
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.google.firebase:firebase-messaging:12.0.1'
this works (firebase console).
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
document is obsolete..., and implementation is blackhole...
so amplify team should make pushnotification's up to date documents and examples, that works well.
I've been having the same issue. I'm thinking about switching to OneSignal too; glad I found this post
Most helpful comment
@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.