I have an app that is listening to incoming UDP packets with NWListener.
I instantiate the listener:
var listener: NWListener?
do {
listener = try NWListener(using: .udp, on: port)
} catch {
print("exception upon creating listener")
}
I implement the stateUpdateHandler:
listener?.stateUpdateHandler = {(newState) in
switch newState {
case .ready:
print("ready")
default:
break
}
}
And of course the handler for new connection where I also start the connection:
listener?.newConnectionHandler = {(newConnection) in
newConnection.stateUpdateHandler = {newState in
switch newState {
case .ready:
print("ready")
default:
break
}
}
newConnection.start(queue: DispatchQueue(label: "newconn"))
}
Finally I receive the message with
connection.receiveMessage { (data, context, isComplete, error) in
// Decode and continue processing data
}
The code works perfectly when the app is actively in the foreground.
What is the recommended approach to keep listening in the background when the user switches to another phone or presses the power button?
I was looking at the "Background Modes"-Capability and first thought about getting this to work with "Background processing", but after some research this does not seem suitable.
Is there any other suitable way to get the UDP listening to work in the background?
The app is also supposed to track the users location as well, also in the background. This would work with "Location updates" I suppose. Correct?
I have written a location tracker test app already and trying to get the location tracking working in the background. I need to test a little more.
In case I get location tracking in the background to work, will then the UDP listener also work in the background?
Any insights highly appreciated!
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am developing an app to control DJI drones by using DJIs Mobile and UX SDK. I am aware, that the problem I am facing might be related to their code, but I am hoping for some pointers on where to look at or things I can try to troubleshoot the issue.
I have explained the issue with code examples and screenshots on Stackoverflow: https://stackoverflow.com/q/67320963/1065468
The remote of the drone is plugged into my iPhone and I start the app through Xcode on my phone wirelessly over the network.
While the app works as it should when started from Xcode, it does not work when I just press the app icon on the iPhone.
Checking my log output of the app on the phone in the console of my Mac, I can see, that the underlying connection to the drone is working and the app should update.
Could it be a difference in configuration when the app is started from Xcode or directly from the phone?
Looking forward to any pointers from you to help me troubleshoot this problem.
In my app, I am performing a VNDetectFaceLandmarksRequest with a VNSequenceRequestHandler. The video that serves as my input is from my iPhones selfie-camera.
The request returns the VNFaceLandmarkRegion2D from where I get all the landmarks as an array of CGPoints via
VNFaceLandmarkRegion2D.normalizedPoints
I want to compare all the CGPoint-arrays over time, but I am not sure if a point at a certain index is always representing the same landmark.
Can I assume that a specific landmark, e.g. the left-most landmark of the right eye, always has the same index in the CGPoint-array?