-
Notifications
You must be signed in to change notification settings - Fork 222
Add Static Location and Live Location Support #3531
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
Merged
Merged
Changes from all commits
Commits
Show all changes
162 commits
Select commit
Hold shift + click to select a range
340f10c
Add static and live location payloads
nuno-vieira 92d15ac
Update the demo app to use static location attachment
nuno-vieira 962ffb4
Add new `ChannelController.sendStaticLocation()` to instantly send a …
nuno-vieira cb365fc
Change the Demo App to send the current location instead of dummy ones
nuno-vieira 8d3b662
Add location background mode to Demo App
nuno-vieira b35f54e
Add staticLocation to the attachments register
nuno-vieira afc3f68
Create a CurrentUserLocationProvider to make it easier to fetch the c…
nuno-vieira 736c08e
Fix not being able to part live location payload
nuno-vieira 154e394
Update DemoApp to support live location attachments
nuno-vieira 3b4d322
Add support for partial message update in MessageUpdater
nuno-vieira b9e1f2c
Expose the Throttler (Revert this, and use it internally)
nuno-vieira ec2f59a
Add `shareLiveLocation()` and `stopLiveLocation()` to `ChannelControl…
nuno-vieira 0a1e120
Refactor logic to fetch current active locations + Improve API
nuno-vieira 61a6a70
Add extra data to location attachment payloads
nuno-vieira 64881a1
Add `LocationAttachmentInfo` to be used as argument
nuno-vieira 6f57eb9
Add `text` to partial message update endpoint
nuno-vieira caf76ab
Add `ChatMessageController.updateMessage()` to support partially upda…
nuno-vieira 5d09df8
Change location live updates APIs
nuno-vieira 667739f
Improve Demo App Location Provider
nuno-vieira 713c5e8
Improve API by observing active live locations messages
nuno-vieira 54d623f
Fixed starting monitoring location whenever an active location was up…
nuno-vieira 495b358
Make the API even easier and add additional delegate methods to know …
nuno-vieira b09bf38
Move the Throttler to LLC, just like the Debouncer
nuno-vieira 6468d0d
Move the Throttling to the current user controller to automatically p…
nuno-vieira effff35
Some minor cleanups
nuno-vieira 1e684db
Simplify currentUserControllerDidStartSharingLiveLocation API
nuno-vieira 81ad0f4
Improve location attachment view
nuno-vieira 9ded30e
Add live location map when tapping the live location attachmen
nuno-vieira 7df6c3e
Animate the user location tracking
nuno-vieira b91fa09
Optimal animation
nuno-vieira e50a63b
Optmizate animation smoothness and server spamm
nuno-vieira 1e9ef44
Add CoreData concurrency flag to StreamDevelopers scheme
nuno-vieira 98afdba
Fix crash when creating the MessageController from a background thread
nuno-vieira 7a0bd66
Fix snapshot chaching
nuno-vieira ecbb7e2
Fix map detail view controller not showing initial position
nuno-vieira ec15a92
Fix avatar view in map view
nuno-vieira 5e3881d
Add pulse animation when live sharing
nuno-vieira 64bcf7e
Refactor LocationDetailViewController to only use the message controller
nuno-vieira f3460be
Refactor code structure of the map detail view controller
nuno-vieira 0af646e
Add bottom sheet to stop location sharing
nuno-vieira 544b506
Add stopLiveLocationSharing() to Message Controller
nuno-vieira 0777d9f
Fix stop sharing button not working
nuno-vieira b2dc128
FIx bottom sheet logic
nuno-vieira 45ad2f1
Add static pin in detail view
nuno-vieira a3a252e
Fix sharing location for other users active location messages
nuno-vieira 6cf17a3
Finish logic for location snapshot view when static vs live
nuno-vieira 26a5e72
Add live location status view in the snapshot view
nuno-vieira e9be9de
Minor cleanup
nuno-vieira 37713b8
Fix copyright
nuno-vieira ef4a214
Fix loading indicator snapshot view
nuno-vieira 722cbfc
Remove support of mixed attachments to locations
nuno-vieira a347d00
Add MessageEndpoints test coverage
nuno-vieira c58a3c3
Add test coverage to message updater
nuno-vieira 776a991
Add test coverage to Message Repository
nuno-vieira d3dfd2e
Add test coverage to message attachments extensions
nuno-vieira 047f962
Add test coverage to parsing attachments
nuno-vieira ea5802e
Add test coverage to MessageDTO
nuno-vieira 4712649
Add message updater mock
nuno-vieira 0a46f19
ActiveLiveLocationAlreadyExists init should not be public
nuno-vieira 6be1283
Add test coverage to Message Controller
nuno-vieira 5044362
Add test coverage to Channel Controller
nuno-vieira 2957975
Fix concurrency issues when stopping and updating the live location a…
nuno-vieira a73406b
Fix Message Controller Tests
nuno-vieira e203dfa
Change updateMessage -> partialUpdateMessage
nuno-vieira 5c30dbe
Add unset support for partial update message
nuno-vieira 1d7ab64
Update CHANGELOG.md
nuno-vieira 251fa84
Fix tests, not compiling because of unset
nuno-vieira a211f5d
Fix test_updatePartialMessage_makesCorrectAPICall
nuno-vieira 5b64e9a
Make `ChatMessageController.updateLiveLocation()` internal
nuno-vieira 95d359f
Update CHANGELOG.md
nuno-vieira a8bf8de
Fix reloading the snapshot when not necesasry
nuno-vieira 9c351a8
Fix avatar view showing for a split second in the snapshot view for s…
nuno-vieira b035ed6
Change location attachment to have dynamic height depending on messag…
nuno-vieira 2ff83a0
Extract avatar size in snapshot view
nuno-vieira 3c0cf34
Fix minor typo
nuno-vieira 601fded
Add fixed width to map snapshot and simplify caching logic
nuno-vieira e8b6587
Use a banner view instead of a sheet in the map detail view
nuno-vieira 61882ef
Present the map instead of pushing when on iPad
nuno-vieira f7dbf60
Add more documentation on how "Tracking" behaviour works
nuno-vieira 7b60602
Enable locations by default in the demo app
nuno-vieira cb135d0
Fix quote message for live location
nuno-vieira f3d7025
Fix location attachments should not be editable
nuno-vieira 5952dd6
Do not show location attachment picker when inside thread
nuno-vieira cd18446
Fix preview message for location attachments
nuno-vieira 77baae2
Fix detail map show Stop Sharing button for another user
nuno-vieira 0765272
Disable locations feature by default
nuno-vieira d06eda0
Add experimental flag
nuno-vieira 37bd1d1
Update CHANGELOG.md
nuno-vieira 81cc2ee
Revert "Disable locations feature by default"
nuno-vieira 2c5b331
Revert "Add experimental flag"
nuno-vieira d7728de
Revert "Update CHANGELOG.md"
nuno-vieira 70fda95
Merge branch 'develop' into add/location-attachments
nuno-vieira 6f277d5
Fix missing stuff from merge conflicts
nuno-vieira 9d2b557
Merge branch 'develop' into add/location-attachments
nuno-vieira 6748eed
Update CHANGELOG.md
nuno-vieira 1048c22
Rename LocationAttachmentInfo to LocationInfo
nuno-vieira 25d3705
Add LocationDTO
nuno-vieira 46c5fc6
Update Atlantis
nuno-vieira d4de8f8
Refactor to new SharedLocation object
nuno-vieira 58653d8
Demo App new Static Location integration
nuno-vieira 5775d32
Merge branch 'develop' into add/location-attachments
nuno-vieira ce36472
Fix Merge Conflicts Errors
nuno-vieira 7ab0dd8
Add new location endpoints
nuno-vieira 356cb17
Implement new stop live location sharing
nuno-vieira 001e2af
Remove stopLiveLocationSharing from ChannelController
nuno-vieira 9311f09
Implement optimistic stop live location sharing
nuno-vieira 9a24297
Add `CurrentUserController.loadLiveLocations()`
nuno-vieira 6c1f1b0
Add new updateLiveLocation endpoint instead of using partial update m…
nuno-vieira 9a4d314
Migrate existing unit tests to the new implementation
nuno-vieira 334c6e4
Fix not possible to open location detail view
nuno-vieira 47cc6c2
Remove unnecessary location optimistic update
nuno-vieira 62fe047
Auto-centering feature
nuno-vieira 875edd8
Fix sharing location of failed messages
nuno-vieira 4b8181f
Fix stopping a live location not triggering didStopLiveLocationSharin…
nuno-vieira c07f7ad
Update CHANGELOG.md
nuno-vieira 97c1e79
Fix parsing active current active location messages
nuno-vieira b4033af
Remove unused message updater in ChannelController
nuno-vieira 96e5fc6
Fix docs typo
nuno-vieira 25a66b0
Add action sheet to select live location in the demo app
nuno-vieira 4ec8960
Make atlantis version static
nuno-vieira efa9b7d
Fix unit tests compilation
nuno-vieira 585d311
Merge branch 'develop' into add/location-attachments
nuno-vieira 332f6fb
Fix removeAllData test
nuno-vieira 37f4290
Remove `didChangeActiveLiveLocationMessages` since it is not needed f…
nuno-vieira e294ac8
Improve docs of current user controller
nuno-vieira f208cdf
Revert "Remove `didChangeActiveLiveLocationMessages` since it is not …
nuno-vieira 2f8d3b7
Make sure live location is changed to not active when reaches the end
nuno-vieira faf1c1e
Forward to the current user delegate event if there was an error upda…
nuno-vieira 4cc09f2
Fix potential memory leak
nuno-vieira 722fa33
Use message updater directly in the current user controller
nuno-vieira 6f114fe
Add option to provide location info from createNewMessage
nuno-vieira 6b27023
Only call didStartSharingLiveLocation or didStopSharingLiveLocation i…
nuno-vieira c157906
Handle multi device logic when updating live location sharing
nuno-vieira 748dfc7
Revert Multi-Device logic for now
nuno-vieira 31c49dd
Fix compilation tests
nuno-vieira 57c9e1e
Add message updater tests
nuno-vieira 1474c65
Add test coverage to loadAllActiveLiveLocations
nuno-vieira 51616bf
Add test coverage to use device Id when creating new live location me…
nuno-vieira 5f4dcd2
Merge branch 'develop' into add/location-attachments
nuno-vieira 406a2be
Merge branch 'add/location-attachments' of github.com:GetStream/strea…
nuno-vieira d3a4fa3
Update CHANGELOG.md
nuno-vieira d9fd593
Merge branch 'add/location-attachments' of github.com:GetStream/strea…
nuno-vieira e0e461b
Fix flaky test_stopLiveLocationSharing_apiFailure_revertsOptimisticUp…
nuno-vieira a879312
Render endAt text in the location attachment images
nuno-vieira 8fd717b
Fix not able to share 1min location
nuno-vieira 4a420b9
Fix auto center button showing in static locations
nuno-vieira 841eac4
Add `channel.config.sharedLocationsEnabled`
nuno-vieira 8dbe9af
Add `canShareLocation` capability
nuno-vieira 1d8f0d9
Add `ChatChannel.activeLiveLocations`
nuno-vieira b1fbd61
Rename LocationDTO -> SharedLocationDTO
nuno-vieira b97e988
Fix Channel.json typo
nuno-vieira 56eed08
Merge branch 'develop' into add/location-attachments
testableapple 2bd4923
Add `ActiveLiveLocationsEndTimeTracker` to track when the endAt is re…
nuno-vieira 34078da
Fix concurrency issue in ActiveLiveLocationsEndTimeTracker
nuno-vieira 972f967
Add missing properties to shared location
nuno-vieira 00c5d8a
Optimistically stop active live location when starting a new one
nuno-vieira 32b25b7
Expose `CurrentUserController.activeLiveLocationMessages`
nuno-vieira ae3694b
Remove outdated comment
nuno-vieira cd5dd03
Add test coverage to ActiveLiveLocationsEndTimeTracker
nuno-vieira f1289ce
Fix the ActiveLiveLocationsEndTimeTracker not triggering an UI Update
nuno-vieira 92a249d
Try to make test less flaky
nuno-vieira 7c8d59d
Add missing docs to `CurrentUserController.loadActiveLocationsMessage…
nuno-vieira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// | ||
// Copyright © 2025 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
import CoreLocation | ||
import Foundation | ||
|
||
enum LocationPermissionError: Error { | ||
case permissionDenied | ||
case permissionRestricted | ||
} | ||
|
||
class LocationProvider: NSObject { | ||
private let locationManager: CLLocationManager | ||
private var onCurrentLocationFetch: ((Result<CLLocation, Error>) -> Void)? | ||
|
||
var didUpdateLocation: ((CLLocation) -> Void)? | ||
var lastLocation: CLLocation? | ||
var onError: ((Error) -> Void)? | ||
|
||
private init(locationManager: CLLocationManager = CLLocationManager()) { | ||
self.locationManager = locationManager | ||
super.init() | ||
} | ||
|
||
static let shared = LocationProvider() | ||
|
||
var isMonitoringLocation: Bool { | ||
locationManager.delegate != nil | ||
} | ||
|
||
func startMonitoringLocation() { | ||
locationManager.allowsBackgroundLocationUpdates = true | ||
locationManager.delegate = self | ||
requestPermission { [weak self] error in | ||
guard let error else { return } | ||
self?.onError?(error) | ||
} | ||
} | ||
|
||
func stopMonitoringLocation() { | ||
locationManager.allowsBackgroundLocationUpdates = false | ||
locationManager.stopUpdatingLocation() | ||
locationManager.delegate = nil | ||
} | ||
|
||
func getCurrentLocation(completion: @escaping (Result<CLLocation, Error>) -> Void) { | ||
onCurrentLocationFetch = completion | ||
if let lastLocation = lastLocation { | ||
onCurrentLocationFetch?(.success(lastLocation)) | ||
onCurrentLocationFetch = nil | ||
} else { | ||
requestPermission { [weak self] error in | ||
guard let error else { return } | ||
self?.onCurrentLocationFetch?(.failure(error)) | ||
self?.onCurrentLocationFetch = nil | ||
} | ||
} | ||
} | ||
|
||
func requestPermission(completion: @escaping (Error?) -> Void) { | ||
locationManager.delegate = self | ||
switch locationManager.authorizationStatus { | ||
case .notDetermined: | ||
locationManager.requestWhenInUseAuthorization() | ||
completion(nil) | ||
case .authorizedWhenInUse, .authorizedAlways: | ||
locationManager.startUpdatingLocation() | ||
completion(nil) | ||
case .denied: | ||
completion(LocationPermissionError.permissionDenied) | ||
case .restricted: | ||
completion(LocationPermissionError.permissionRestricted) | ||
@unknown default: | ||
break | ||
} | ||
} | ||
nuno-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
extension LocationProvider: CLLocationManagerDelegate { | ||
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { | ||
let status = manager.authorizationStatus | ||
if status == .authorizedWhenInUse || status == .authorizedAlways { | ||
manager.startUpdatingLocation() | ||
} | ||
} | ||
|
||
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { | ||
guard let location = locations.first else { return } | ||
didUpdateLocation?(location) | ||
lastLocation = location | ||
onCurrentLocationFetch?(.success(location)) | ||
onCurrentLocationFetch = nil | ||
} | ||
|
||
func locationManager(_ manager: CLLocationManager, didFailWithError error: any Error) { | ||
onError?(error) | ||
} | ||
nuno-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.