When calling initializePushNotifications, the library calls an internal updateEndpoint API. Anytime updateEndpoint is called, it automatically populates the demographic property with client info and the userId with the identity id. When calling identifyUser, these values can be provided explicitly but will always be pre-populated. This can have unexpected consequences since initializePushNotifications is typically called on every app launch - and it will opaquely overwrite existing values previously set on the endpoint.
This PR updates the updateEndpoint API to only pre-populate these fields when creating an endpoint to avoid repeatedly overwriting the endpoint with the default/fallback values.
Added unit tests that were expected to fail prior to code changes and verified they are now passing
Tested on sample app to see that demographic and userId are only on the network request when an endpoint has yet to be cached (endpoint creation) and subsequent calls do not.
Description of changes
When calling
initializePushNotifications
, the library calls an internalupdateEndpoint
API. AnytimeupdateEndpoint
is called, it automatically populates thedemographic
property with client info and theuserId
with the identity id. When callingidentifyUser
, these values can be provided explicitly but will always be pre-populated. This can have unexpected consequences sinceinitializePushNotifications
is typically called on every app launch - and it will opaquely overwrite existing values previously set on the endpoint.This PR updates the
updateEndpoint
API to only pre-populate these fields when creating an endpoint to avoid repeatedly overwriting the endpoint with the default/fallback values.Issue #, if available
https://github.com/aws-amplify/amplify-js/issues/13174
Description of how you validated changes
yarn test
demographic
anduserId
are only on the network request when an endpoint has yet to be cached (endpoint creation) and subsequent calls do not.Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.