amplify-js: PushNotification does not appear to add device token to endpoint
I’ve added Push Notifications to an empty React Native test project. I’m experimenting on Android at the moment.
"@aws-amplify/pushnotification": "^1.1.4",
"amazon-cognito-identity-js": "^3.2.0",
"aws-amplify": "^1.2.4",
"aws-amplify-react-native": "^2.2.3",
"react": "16.9.0",
"react-native": "0.61.4"
My App.js looks like this:
import React, {useEffect} from 'react';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
import PushNotification from '@aws-amplify/pushnotification';
Amplify.Logger.LOG_LEVEL = 'DEBUG';
Amplify.configure(awsconfig);
PushNotification.configure(awsconfig);
...
function App(props) {
useEffect(() => {
PushNotification.onNotification(notification => {
console.log('in app notification', notification);
});
PushNotification.onRegister(token => {
console.log('in app registration', token);
});
PushNotification.onNotificationOpened(notification => {
console.log('the notification is opened', notification);
});
}, []);
...
}
export default App;
When I look at the logfiles, the only line that appears interesting is:
LOG [DEBUG] 03:54.327 AWSPinpointProvider - updateEndpoint with params: {"ApplicationId": "xxxxxxxx", "EndpointId": "xxxxxxxxxx", "EndpointRequest": {"Attributes": {}, "ChannelType": undefined, "Demographic": {"AppVersion": "/", "Make": "ReactNative", "Model": "", "ModelVersion": "", "Platform": undefined}, "EffectiveDate": "2019-11-21T21:03:54.325Z", "Location": {}, "Metrics": {}, "RequestId": "xxxxxxxx", "User": {"UserAttributes": [Object], "UserId": "..."}}}
There are no “Notification” debug lines.
From looking at PushNotification.ts I believe that the PushNotification.configure function should later update that same endpoint to add the Token and ChannelType, but it doesn’t appear to do that.
When I run a test:
aws pinpoint get-endpoint --application-id xxxxxx --endpoint-id xxxxxx
the result is
{
"EndpointResponse": {
"ApplicationId": "xxxxxxxxx",
"Attributes": {},
"CohortId": "21",
"CreationDate": "2019-11-21T21:03:54.325Z",
"Demographic": {
"AppVersion": "/",
"Make": "ReactNative",
"Model": "",
"ModelVersion": ""
},
"EffectiveDate": "2019-11-21T21:03:54.325Z",
"EndpointStatus": "ACTIVE",
"Id": "xxxxxxx",
"Location": {},
"Metrics": {},
"OptOut": "ALL",
"RequestId": "xxxxxxx",
"User": {
"UserId": "xxxxxxx"
}
}
}
with no device token or channel set.
As a result, if I try to send a test push notification using the Pinpoint console to that endpoint, it errors “Endpoints must have an address to target.” However, the Firebase console can see my mobile device and send test push notifications to it.
Why is the endpoint not being updated properly in Pinpoint?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15
@Munish-GitHub did you found a solution?
well maybe it works just on Android then. Because when I try to run
Analytics.updateEndpointwith user data (userId, attributes, etc), I get an error saying that the endpoint is missing an address (which is the notification token)