-
Notifications
You must be signed in to change notification settings - Fork 33
[SDK-289] Fixed double callback problem for setEmail with auto push registration #985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[SDK-289] Fixed double callback problem for setEmail with auto push registration #985
Conversation
a70950b to
18cab40
Compare
Ayyanchira
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made some comments
iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppManager.java
Show resolved
Hide resolved
| static JSONObject setEmailLocalSuccessResponse = new JSONObject(Map.of("message", "setEmail was completed locally, but still requires the register device call. If possible, use autoPushRegistration.")); | ||
|
|
||
| static JSONObject setReadLocalSuccessResponse = new JSONObject(Map.of("message", "setRead was completed locally, no remote call was done yet.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why these are static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think for it to be retain its value throughout the flow ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in order to work as the kotlin object, so we can just call the class without instantiating it and for the class to just be a container of these responses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this object initialized when the app starts without having called setEmail and inAppRead?
Another point to look at is:
If multiple inapps are getting read, is there a possibility of these handlers to behave differently than expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the fields are initialized when the app starts.
The handlers are not changing at all, only the json that is getting returned
🔹 Jira Ticket(s) if any
✏️ Description
This fix is meant to be a more straight forward fix for the double callback issue some clients have encountered when autoPushRegistration is set to false.
Root cause:
When autoPushRegistration is false and we call setEmail, no remote call is made to actually update the current user in the iterable app, so we wait for the push registration to be made to consider it completely done.
Because some users were using the callbackHandler within a couroutine, when the registerDeviceToken was called we would wrap the setEmail callback into the registerDeviceToken call, so we could notify when the setEmail flow was actually completed, but that caused the callback to fire twice, and if the coroutine was dependant of a success to continue that would cause the app to crash.
The Solution:
To clear the success handler when it is called on autoPushRegistration = false, so when the user calls for registering the device we won't cause the same success handler to fire twice.
Also some better responses are provided for better understanding of the process and why things are happening this way.