-
Notifications
You must be signed in to change notification settings - Fork 26
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
Call to the registerForRemoteNotifications
#1293
Call to the registerForRemoteNotifications
#1293
Conversation
… old one. (Draft)
…with the old one. (Draft)" This reverts commit afa4d59.
…rRemoteNotifications within the framework
registerForRemoteNotifications
and unregisterForRemoteNotifications
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.
I have a couple of questions around the changes being made to the activate
and deactivate
methods:
- Is there a risk that calls to these methods, or other methods altering state, could overlap one another? I'm not familiar with this code, so there may be external factors guaranteeing this, however I can't documentation indicating that (for example: these methods aren't safe to be called from any thread, or can only be called in very specific circumstances).
- Perhaps related, do methods on the shared application instance have to be called from the main thread? Looking at this code comment it appears that calls to the delegate might be.
Thanks @QuintinWillison, that's a good spot. Regarding overlapping, I've created this issue - ably/ably-flutter#345, so |
I think that we can’t avoid In terms of consequences of |
@QuintinWillison @maratal as mentioned in #1271, we need to remove the step where the user calls |
@maratal in terms of testing:
|
Yes, I have simple demo app that does just that. I plan to convert it to SwiftUI according to #1318
I think yes, I need to investigate this. UPD: changes here - 3cece2e |
registerForRemoteNotifications
and unregisterForRemoteNotifications
registerForRemoteNotifications
…registerForRemoteNotifications
Thanks for the updates @maratal, I've resolved my code-level comments. Did you or @QuintinWillison have thoughts on this question and this one? |
@lawrence-forooghian Regarding the REST API PATCH endpoint, I'm going to find it very difficult to gain enough context to form an opinion without spending more time than I could possibly find right now to dig around. I'm not familiar with this code. The documented constraints on what fields can be updated via that endpoint suggest that calling it multiple times needs to be considered very carefully. 🤷 In respect of your question around updating examples and documentation, I don't think that needs to block this pull request from landing, especially if it does end up being decided that multiple calls to |
I think my uncertainty / worry was that we'd merge this PR and then forget about the documentation work. How do we usually handle this sort of thing? |
@lawrence-forooghian In order not to forget, we would usually create an issue in |
@lawrence-forooghian @QuintinWillison Turned out it doesn't matter how many times in a raw you call |
|
According to the issue, a call to the
registerForRemoteNotifications:
should be included somewhere to simplify the initial setup process for the cocoa framework. But the main "headache" and a startup "noise" is this:So, I've introduced a new
activate:
method with theUNAuthorizationOptions
parameter to justify that, whereas its old counterpart optionlessactivate
method calls the new one with the default set of options.This has raised a concern of a possible interfere of the new
activate
method behavior with existing apps startup logic, which is true and further discussion about it is here.In addition to that, I've created a new handler for
application:didRegisterForRemoteNotificationsWithDeviceToken
which is rather than being "handler" is now a method for saving on a device and registering the new token within Ably infrastructure:registerAPNSDeviceToken:
, signature of which much easier to comprehend in oppose todidFailToRegisterForRemoteNotificationsWithError:rest:
.The new one just calls the old one, because it already implements what is needed. In the following commits I'm going to flip their bodies, because the old handlers should eventually be removed.
These two changes allow to setup ably-cocoa and APNs in just two lines of code:
Which is way more welcoming in comparing to Step 6 ad Step 7 of the tutorial https://ably.com/tutorials/ios-push-notifications#step6-register-device-for-push