I want to determine if I am within a 10m radius of an area on my iphone's location information, but when I wait for the result and then go to the next process, the result of the inside/outside determination does not come back.
Please tell me if I am doing something wrong.
func SpotArea_judgment(place: String, rad: Int, location:CLLocationCoordinate2D) -> Bool? {
var result: Bool?
let semaphore = DispatchSemaphore(value: 0)
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(place) { (placemarks, error) in
let center = CLLocationCoordinate2D(
latitude: Double(placemarks?.first?.location?.coordinate.latitude ?? 0),
longitude: Double(placemarks?.first?.location?.coordinate.longitude ?? 0)
)
let radius: CLLocationDistance = Double(rad)
let circularRegion = CLCircularRegion(center: center, radius: radius, identifier: "identifier")
result = circularRegion.contains(location)
semaphore.signal()
}
semaphore.wait()
return result
}
Post
Replies
Boosts
Views
Activity
I would like to know the status of a dead battery when the application is running, but is there any way to get the status just before the battery runs out?
Is there any way to get the status of the battery right before it runs out?
UIDevice.current.isBatteryMonitoringEnabled = true
UIDevice.current.batteryLevel
but please tell us how to get the status of power off, etc. as well.
I'm working on porting the source of an app I took from a sample to an app I created by myself by changing it to SwiftUI.
I don't know how to port the following CXProviderDelegate.
If I port it as is
If I port it as-is, I get an error saying that the non-class type 'VideoView' cannot conform to class protocol 'CXProviderDelegate'.
Please let me know how to port it.
extension videoTabView: CXProviderDelegate {
func providerDidReset(_ provider: CXProvider) {
}
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
callCenter.ConfigureAudioSession()
callCenter.Connecting()
action.fulfill()
}
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
callCenter.ConfigureAudioSession()
if let peer = self.dataConnection?.peer {
self.call(targetPeerId: peer)
}
action.fulfill()
}
func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
self.dataConnection?.close()
self.mediaConnection?.close()
action.fulfill()
}
}
It is developed using CallKit.
I want to open a specific page when a phone call is received in the foreground or background.
Please tell me how to direct a specific page.
Hi, I am creating an application with SwiftUI using CoreLocation.
When I set the positioning system to kCLLocationAccuracyBest, the system does not appear.
When I view it in GoogleMap, it sometimes shows me as if I am in a house instead of a street.
Please let me know how I can improve the system.
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate{
var locationManager : CLLocationManager?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool{
locationManager = CLLocationManager()
locationManager!.delegate = self
locationManager!.requestAlwaysAuthorization()
if CLLocationManager.locationServicesEnabled(){
locationManager!.desiredAccuracy = kCLLocationAccuracyBest
locationManager!.distanceFilter = 10
locationManager!.allowsBackgroundLocationUpdates = true
locationManager!.pausesLocationUpdatesAutomatically = false
locationManager!.startUpdatingLocation()
}
return true
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){
guard let newLocation = locations.last else {
return
}
let location: CLLocationCoordinate2D = CLLocationCoordinate2DMake(newLocation.coordinate.latitude, newLocation.coordinate.longitude)
Can I use Google MobileAds with SwiftUI?
When I search on the web, I see that I need UIkit, but can I use SwiftUI only?
In SwiftUI, tapping the search button does not switch to the search page.
Both SrhView () and PutView () do not switch the page.
.navigationBarTitle("Title", displayMode: .inline)
.navigationBarItems(
leading:
Button(action: {
SrhView()
}) {
Image(systemName: "magnifyingglass")
},
trailing:
Button(action: {
PutView()
}, label: {Text("PUt")}
))
I'm currently working on an iPhone app with Xcode12 and Swift for notifications with an 8am survey, but I need the notifications to have an action. Is there any way to show the button in a dialog-like way from the beginning?
I'm currently working on an iPhone app with Xcode12 and Swift for notifications with an 8am survey, but I need the notifications to have an action. Is there any way to show the button in a dialog-like way from the beginning?