-
Notifications
You must be signed in to change notification settings - Fork 211
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
Add Static Location and Live Location Support #3531
base: develop
Are you sure you want to change the base?
Conversation
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.
Couldn't test a lot, since a had constant crashes (shared details on Slack). Let's figure that out first, then I will do another round.
userName: String | ||
) { | ||
if let existingAnnotation = userAnnotation { | ||
UIView.animate(withDuration: 5) { |
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.
why do we need to do 5 second long animation?
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.
This is mostly to have a smooth animation. It simulates the pin constantly being moved since the animation is always running. It looks quite good this way. But it is also possible to have an hard animation like WhatsApp, but for now this is quite smooth
client?.registerAttachment(LocationAttachmentPayload.self) | ||
|
||
// Custom Attachments | ||
if AppConfig.shared.demoAppConfig.isLocationAttachmentsEnabled { |
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 think it should be always on, since it's the demo app. Our config screen becomes very complex at this point.
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 was disabled by default before, but since we now support locations out of the box, I can enable it by default. That said, I prefer not to do so because it involves sensitive data. Customers could easily misuse it and potentially spam our server.
…location message to a channel
…urrent user location
…when the user should start and stop location sharing
…rotect against abusive updates
5e5a9ab
to
70218c2
Compare
Generated by 🚫 Danger |
SDK Size
|
/// In order to | ||
/// | ||
/// - Parameters: | ||
/// - location: The location information. | ||
/// - text: The text of the message. | ||
/// - extraData: Additional extra data of the message object. | ||
/// - completion: Called when saving the message to the local DB finishes, | ||
/// not when the message reaches the server. |
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.
Seems like a formatting issue
public func sendStaticLocation( | ||
_ location: LocationAttachmentInfo, | ||
text: String? = nil, | ||
messageId: MessageId? = nil, | ||
quotedMessageId: MessageId? = nil, | ||
extraData: [String: RawJSON] = [:], | ||
completion: ((Result<MessageId, Error>) -> Void)? = 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.
Planning to add similar functions to Chat
?
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.
Should we move most of the logic in these action methods to separate handler/sender for making them reusable for Chat
?
TypingEventsSender
, ReadStateHandler
?
/// - attachments: The attachments to be updated. | ||
/// - extraData: The additional data to be updated. | ||
/// - completion: Called when the server updates the message. | ||
public func updateMessage( |
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.
partialUpdateMessage
/partialMessageUpdate
for matching to the common naming pattern?
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.
The reason I did not put this name is because editMesasge is kinda already a partial update as well. All the existing data will remain the same. At least the end result will be the same, even though internally we provide the non-changed data to the server.
The only real diff between the editMessage, and updateMessage, is that one is scheduled, and the other one is not 🤔
final class ActiveLiveLocationAlreadyExists: ClientError { | ||
let messageId: MessageId | ||
|
||
public init(messageId: MessageId) { |
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.
Internal?
@@ -1766,7 +1955,7 @@ private extension ChatChannelController { | |||
|
|||
// MARK: - Errors | |||
|
|||
extension ClientError { | |||
public extension ClientError { |
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.
Keeping it internal?
🔗 Issue Links
Resolves https://linear.app/stream/issue/IOS-578/location-attachment
🎯 Goal
Adds support for static and live location attachments in the Low-Level Client SDK.
The UI has been implemented in the Demo App to demonstrate how to use the new location APIs.
A guide should be written in the stream documentation on how to use the location APIs.
📝 Summary
New APIs:
ChatChannelController
sendStaticLocation()
- Sends a static location message to the channel.startLiveLocationSharing()
- Starts a live location-sharing message in the channel.stopLiveLocationSharing()
- Stops sharing the live location message in the channel.ChatMessageController
updateMessage()
- Updates the message partially. (It was missing from the SDK)updateLiveLocation()
- Updates the message's live location attachment if it has one.stopLiveLocationSharing()
- Stops sharing the live location attachment if it has one.CurrentChatUserController
updateLiveLocation()
- Updates the location of all active live location messages for the current user. Internally, it uses the Message Controller to update each message that has a live location attachment.CurrentChatUserControllerDelegate
didStartSharingLiveLocation()
- Notifies whenever the current user is sharing a live location.didStopSharingLiveLocation()
- Notifies whenever the current user stops sharing a live location.didChangeActiveLiveLocationMessages()
- Notifies whenever the live location messages update.Throttler
ChatMessage
staticLocationAttachments
- Returns the attachments of.staticLocation
type.liveLocationAttachments
- Returns the attachments of.liveLocation
type.AttachmentType
.staticLocation
.liveLocation
ChatMessageLiveLocationAttachment
&LiveLocationAttachmentPayload
ChatMessageStaticLocationAttachment
&StaticLocationAttachmentPayload
Out of Scope
🛠 Implementation
TODO
🎨 Showcase
Demo:
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2025-01-03.at.17.38.38.mp4
🧪 Manual Testing Notes
TODO
☑️ Contributor Checklist