-
Notifications
You must be signed in to change notification settings - Fork 4
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
We do not explain how a client lib should populate LocalDevice.push
#25
Comments
➤ Phil Leggetter commented: is blocking SDK work. See https://ably-real-time.slack.com/archives/C01LUEUC9GT/p1652888449704039 ( https://ably-real-time.slack.com/archives/C01LUEUC9GT/p1652888449704039|smart-card ) |
As mentioned on Slack, @paddybyers, it would be great to get your opinion on this one. |
Agreed
These were intended to capture the terminal state of the activation state machine. In particular, if activation fails and the stae machine ends up in a failed state, then these values are captured in the local device. Then, any attempted operations that are contingent on activation having happened (eg anything relating to local device subscriptions, that depend on local device authentication) can return the appropriate error. That was the idea. I can't look further into the linked discussions right now, but lmk if this helps |
In according what @paddybyers said
I could just save these values upon error in the activation process both on Apple or Ably side, and then when calling methods "relating to local device subscriptions" I can check whether an error was saved into the
I also keen to this solution, but I think removing |
@maratal I've taken a look at your draft PR ably/ably-cocoa#1441, which, effectively, removes But, I just wanted to also explore @paddybyers's idea for how First, to summarise what Paddy is suggesting, I think it’s the following:
And then, as for how that might benefit us, it would mean that when a user calls a method that requires the local device to already be activated for push notifications – specifically, these are I'd like to understand better this part of your objection:
If I've understood correctly, you're saying that, each time the user calls |
Ah, one other thing I wanted to mention. I think that, if we do keep the |
Yeah, seems like I've jumped into conclusions here, looks like saving error is still useful, will do. |
There is a problem with this - not all failures end up in a failed state of the state machine. There are 4 events representing failure, and only 2 states for it. After, for example, |
Regarding inheritance - there are still a lot of common properties between these two classes:
I think inheritance still makes sense. I've added these two
in a private part of the |
That's a good point. Perhaps we should always save an error whenever one occurs, and then the above-suggested "mapping from state machine state to one of (Brain not 100% working yet, will come back to this one when I’m properly back from holiday.) |
➤ Automation for Jira commented: The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-2765 |
What's the issue?
LocalDevice
extendsDeviceDetails
, which has apush: DevicePushDetails
property. The features spec does not provide any guidance on how a client library should populate this property for aLocalDevice
instance.(This only applies to
LocalDevice
instances. A non-LocalDevice
instance ofDeviceDetails
is the result of a call to one of the push admin REST APIs, in which all of these properties will have been populated by the backend.)Let's look at each of the properties of
DevicePushDetails
in more detail:errorReason: ErrorInfo?
andstate: .Active | .Failing | .Failed
: I believe these are meant to describe whether the Realtime backend was able to successfully send push notifications to that device.recipient: JsonObject
: This describes the parameters that the Realtime backend needs in order to send push notifications to that specific device ("push transport details" as the features spec calls them). Its value is best described by the REST API documentation for the "register a device for receiving push notifications" operation. For example, on iOS, it's{ transportType: "apns", deviceToken: <string> }
, wheredeviceToken
is a value that was originally provided to the client library by iOS.What does the features spec imply?
recipient
propertyThe features spec implies, but does not explicitly state, that the
LocalDevice.push.recipient
property should be populated when the client library receives updated push transport details from its environment (OS, browser, …), and should be used to store these details. This is how the current iOS implementation behaves.In the features spec, this requirement is primarily implied by (emphasis mine):
RSH3a2c
:RSH3a2d
:RSH3d3b
:RSH8i
:errorReason
andstate
propertiesThe features spec makes no mention of how
LocalDevice.push.{errorReason, state}
should be populated.Suggested solution
recipient
propertyWe should explicitly document how a client library is expected to populate this property, in line with what’s currently implied. We should also use this opportunity to make sure that the guidance we give about storing push transport details locally is compatible with the advice of client platform vendors, for example Apple’s guidance to “never cache device tokens in local storage” (which I think needs to be interpreted not as “don’t store”, but “make sure to validate your stored data”).
errorReason
andstate
propertiesThis data is potentially useful for a client library to expose, as described in "When is this useful?" of #26.
We have two options for exposing it:
LocalDevice
interface, and then describe a mechanism for explicitly fetching this data separately. This would be a (in theory, but not in practice since these properties never did anything useful) breaking change to the public API of the library. We’d also have to find a way to handle the fact that these properties exist in its parentDeviceDetails
interface (e.g. remove the inheritance).My preference would be the latter. I can’t think of a use case that requires this data to be updated in real time, and it would add substantial complexity.
Other conversations / issues
Push#getDevicePushDetails method to make HTTP request #26 – here it’s decided that the backend will update the "get details from a registered device" REST API operation to work for the current device without requiring push admin, hence partly implementing solution 2 above. Related client SDK issues:
LocalDevice.push.state
andDeviceDetails.push.state
is always null ably-flutter#146state
returned inARTLocalDevice
/ARTDeviceDetails
ably-cocoa#1162state
returned inLocalDevice
/DeviceDetails
ably-java#697New ARTPush/getDevicePushDetails method for simplifying push state access ably-cocoa#1186 – ably-cocoa attempt to address this issue, by taking advantage of the backend change described above.
┆Issue is synchronized with this Jira Task by Unito
The text was updated successfully, but these errors were encountered: