Posts

Post not yet marked as solved
1 Replies
211 Views
In our app we have the necessity to gather background location after a trigger from a bluetooth event. During the onboarding we ask for authorizedWhenInUse. CLLocationManageris configured like this, and in capabilities we provided the location flag. let cl = CLLocationManager() cl.delegate = self cl.allowsBackgroundLocationUpdates = true cl.desiredAccuracy = kCLLocationAccuracyBestForNavigation According to apple doc or at least what I understood, this should be enough to obtain locations even when the app is in background (and awake). The system allows background updates for apps with either When in Use or Always authorization. If an app isn't running when an update occurs, the system launches the app only if it has Always authorization and uses the significant location change, visits, or region monitoring services. We saw an inconsistent bahviour, the system request to start the location updates after the bluetooth event (we have background capabilities set also for that). In foreground it work always, but in background sometimes it works and sometimes not. When we don't receive a location we usually get a CLError.denied in the func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) method. At this point I don't get the apple doc quote, is it possible to obtain location in background or not with authorizedWhenInUse?
Posted
by DrAma78.
Last updated
.
Post not yet marked as solved
1 Replies
214 Views
I'm experiencing that issue but not on all devices, right now we are able to see a consistent behavior on iPhone 8 with iOS 16.7.5. The NSProcessInfoPowerStateDidChange is never called and the state is never updated during the same app session, it keeps returning the same value. Most weird the systemUptime changes, isLowPowerModeEnabled is the only state that never changes. Tried different approach even polling but the result is always the same. the problem doesn't seems to be in the code, even DataDog SDK (integrated in the same app), that asks the isLowPowerModeEnabled to understand if it could upload logs is affetcted by the same issue. protocol SystemPowerInfoProvider { var isLowPowerModeEnabled: AnyPublisher<Bool, Never> { get } } final class DefaultSystemBatteryOptimizationStateProvider: SystemPowerInfoProvider { var isLowPowerModeEnabled: AnyPublisher<Bool, Never> { _isLowPowerModeEnabled } private lazy var _isLowPowerModeEnabled: AnyPublisher<Bool, Never> = { return Just(ProcessInfo.processInfo.isLowPowerModeEnabled) .merge(with: NotificationCenter.default .publisher(for: Notification.Name.NSProcessInfoPowerStateDidChange) .map { notification -> Bool? in guard let processInfo = notification.object as? ProcessInfo else { return nil } return processInfo.isLowPowerModeEnabled } .compactMap { $0 } ) .eraseToAnyPublisher() }() }
Posted
by DrAma78.
Last updated
.
Post not yet marked as solved
2 Replies
341 Views
In iOS17 this new option has been added in the peripheral connection option CBConnectPeripheralOptionEnableAutoReconnect The documentation states: After a peripheral device connects, this setting enables the system to initiate a connection to the peer device automatically when the link drops. The system uses centralManager(_:didDisconnectPeripheral:timestamp:isReconnecting:error:) to notify the caller about the disconnection. To get the same behavior I used to schedule a new connection after a disconnection depending on the error type. I'm trying to understands if the are more benefits using that flag instead the of "old" way. Can someone clarify that? Best, Andrea
Posted
by DrAma78.
Last updated
.
Post not yet marked as solved
0 Replies
326 Views
Experimenting with Combine, I've seen this behavior but I can't explain why is happening. I'm not trying to achieve nothing in particular so the example doesn't make any sense, I'm just trying to understand why is this happening. let cvsOne = CurrentValueSubject&lt;Int, Never&gt;(0) let cvsTwo = CurrentValueSubject&lt;Int, Never&gt;(5) let canc =  [0,1,2,3].publisher .flatMap { (_) in     return cvsOne } .flatMap { (_) in     return cvsTwo } .sink { (value) in     print("Received \(value)") } From the print statement in the sink I get : Received 5 Received 5 Received 5 Received 5 And it's ok. If I add I send anther value to the cvsTwo, while I'm expecting just one value printed from sink I get the value sent repeated 4 times that is the count of the array elements. cvsTwo.send(10) Received 10 Received 10 Received 10 Received 10 I really do not understand why, attaching print to the publishers flow I see that the array publisher complete with a finish event, but it seems that right after I send the value is triggered again. receive subscription: ([0, 1, 2, 3]) request unlimited receive value: (0) Received 5 receive value: (1) Received 5 receive value: (2) Received 5 receive value: (3) Received 5 receive finished Received 10 Received 10 Received 10 Received 10 Can someone explain that to me?
Posted
by DrAma78.
Last updated
.