-
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
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.
...treamChat/Components/CustomAttachments/LocationAttachment/LocationDetailViewController.swift
Outdated
Show resolved
Hide resolved
5e5a9ab
to
70218c2
Compare
Generated by 🚫 Danger |
SDK Size
|
Sources/StreamChat/Controllers/ChannelController/ChannelController.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Controllers/ChannelController/ChannelController.swift
Show resolved
Hide resolved
Sources/StreamChat/Controllers/MessageController/MessageController.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Controllers/ChannelController/ChannelController.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Controllers/ChannelController/ChannelController.swift
Show resolved
Hide resolved
Sources/StreamChat/Controllers/ChannelController/ChannelController.swift
Show resolved
Hide resolved
Sources/StreamChat/Controllers/ChannelController/ChannelController.swift
Show resolved
Hide resolved
Sources/StreamChat/Controllers/CurrentUserController/CurrentUserController.swift
Show resolved
Hide resolved
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.
Looks good! Left few comments, let me know what you think.
...eamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift
Outdated
Show resolved
Hide resolved
...eamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Controllers/MessageController/MessageController.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Controllers/CurrentUserController/CurrentUserController.swift
Show resolved
Hide resolved
...eamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift
Show resolved
Hide resolved
...eamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift
Show resolved
Hide resolved
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.
LGTM! ✅
...eamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift
Show resolved
Hide resolved
502d6b5
to
f1a4fac
Compare
…tatic attachments
f1a4fac
to
37bd1d1
Compare
Quality Gate passedIssues Measures |
🔗 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.
📝 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
The SDK at the moment only handles updating the location attachments. The location tracking should be provided by the App. Something like the
LocationProvider
in the Demo App should be implemented by the customer.Creating a location attachment
In order to create a new message with a location attachment, the developer can use the
ChannelController.sendStaticLocation()
or theChannelController.startSharingLiveLocation()
. If more fine control is needed, it is also possible to add the attachments by using theChannelController.createNewMessage()
and pass the location attachment payload as an argument.Sending location updates (Live Location)
The customer is responsible for sending new location updates to the SDK. This is done through the
CurrentChatUserController.updateLiveLocation()
method. This method will update all the current user's active location attachments. Internally, it uses aactiveLiveLocationMessagesObserver
that keeps track of the active location attachments of the current user. These changes are also available to the customer through theCurrentChatUserControllerDelegate
to make it easier for the developer to know when it should track location updates and when it can turn them off.Stopping live location attachment
To stop a live location attachment, it can be done through 2 methods:
ChatChannelController.stopLiveLocationSharing()
: This one will automatically get the current active location attachment in that channel and stop it.ChatMessageController.stopLiveLocationSharing()
: Directly tries to stop a live location attachment in the given message if it has an active location attachment. This is especially useful in Message Actions, where having the ChannelController is not possible or difficult.Overall Data Flow
🎨 Showcase
static.mp4
live.mp4
🧪 Manual Testing Notes
Note: To simulate live location updates in the Simulator, with the Simulator selected, Go to
Features > Location > City Bicycle Ride
in the top bar of the Mac.Static
Live
Make sure to test from the current user's perspective and the other user's perspective.
☑️ Contributor Checklist