fix(push): Prevent Unintended OptOuts #2587
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
Issue #1
During Amplify's configuration, a call is made to the FirebaseMessaging sdk to grab the token. However, this call is asynchronous (FirebaseMessaging.getInstance().token.addOnCompleteListener) and if a Amplify.Notifications.Push.identifyUser() call is made before the token is returned, it will not locate the token and send OptOut = NONE.
Issue #2
Amplify Push Notifications and Amplify Analytics are appearing to conflict with one another. Each library updates the same endpoint/profile. Each time an analytics endpoint is sent (or even configured), it will send an endpoint update without the token and push channel type. This results in OptOut = All getting set. I was able to observe this by creating a sample app with 2 buttons. The first button called Amplify.Notifications.Push.identifyUser(). The second button called Amplify.Analytics.identifyUser(). When the push button was clicked, the profile was updated with OptOut = NONE. When the analytics button was clicked, OptOut = ALL becomes set.
How did you test these changes?
(Please add a line here how the changes were tested)
Documentation update required?
General Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.