-
Notifications
You must be signed in to change notification settings - Fork 74
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
[MOB-6055] callback on setEmail/setUserId #629
Conversation
@roninopf Could you please start review for this ? |
@devcsomnicg Will do! Would you like to look over the tests as well? |
@roninopf updated code and tests, could you please run the tests again |
Will have to resolve the conflict. But looks like its replacing the existing method with one with additional parameter. As like for other SDKs, we should have additional methods for the ones with completionHandlers. This is to avoid breakages for developers who would just update to newer versions of SDK |
@Ayyanchira done, added additional methods. |
@Ayyanchira Updated this with suggestions on PR. please review |
1 similar comment
@Ayyanchira Updated this with suggestions on PR. please review |
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.
Added some comments. Merging to omni cg branch for internal testing. Looks good so far.
@@ -111,7 +111,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider { | |||
_payloadData = data | |||
} | |||
|
|||
func setEmail(_ email: String?, authToken: String? = nil) { | |||
func setEmail(_ email: String?, authToken: String? = nil, successHandler: OnSuccessHandler? = nil, failureHandler: OnFailureHandler? = nil) { |
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.
Had initial thought that we might need additional functions with and without handlers as we do in Android. But looks like having optional parameters makes it modern and lets us have only one signature instead of bloating up the IterableApi class. 👍🏼
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.
@Ayyanchira ok so for this we are good right ?
@@ -428,6 +440,9 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider { | |||
private var _email: String? | |||
private var _payloadData: [AnyHashable: Any]? | |||
private var _userId: String? | |||
private var _successCallback: OnSuccessHandler? = nil |
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.
If this is going to be global but only used for setting the user credentials, we might have to rename it that way. Because, we will be adding success failure callbacks to other api calls / function calls as well and they will have to pass in success and failure callbacks too. using this global variable to store that and replace whats been stored in that can cause inconsistent behaviors
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.
Like for example, updateEmail also uses success and failure callback handler to notify the state. But by not having it stored globally, it allows for good separation.
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.
@Ayyanchira yes we can rename it so that is identified differently, but it would be class variable because it is used from the whole different method and that is why we need to hold a reference to it
Checked and its working well. So lets go ahead with current changes as it is for now until other methods also start needing success and failure callback handlers. |
Test methods are failing @devcsomnicg . It looks like setEmail leads to |
I am not sure about where this code is AppExtensionHelper.application.registerForRemoteNotifications() but, to give you a example when you do registerForRemoteNotifications it calls this function didRegisterForRemoteNotificationsWithDeviceToken here https://github.com/Iterable/swift-sdk/blob/5c033ded01e200acee52c9bd1fca377dbdcbbbce/sample-apps/swift-sample-app/swift-sample-app/AppDelegate.swift#L105. |
Added a call to registerDevice() with no success failure callback after setEmail -> here in this PR. This commit. |
🔹 Jira Ticket(s)
✏️ Description