Estimote / iOS-Proximity-SDK

Estimote Proximity SDK for iOS
https://developer.estimote.com
Apache License 2.0
61 stars 26 forks source link

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] #44

Open vinodgleecus opened 5 years ago

vinodgleecus commented 5 years ago

I just implemented this simple method to fetch all available tags/zones

import UIKit import Parse import EstimoteProximitySDK

class HomeViewController: UIViewController {

let estimoteCloudCredentials = CloudCredentials(appID: "xxxxxxxx", appToken: "xxxxxxxxxxxxx")
var proximityObserver: ProximityObserver!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    self.tabBarController?.title = "HOME"

    DispatchQueue.main.async {
        self.loadNearByBeacons()
    }
}

private func loadNearByBeacons(){

    self.proximityObserver = ProximityObserver(
        credentials: estimoteCloudCredentials,
        onError: { error in
            print("proximity observer error: \(error)")
    })

    let blueberryZone = ProximityZone(tag: "DevOffice", range: ProximityRange.custom(desiredMeanTriggerDistance: 1.0)!)
    blueberryZone.onEnter = { zoneContext in
        print("Entered near range of tag 'DevOffice'. DeviceIdentifier: \(zoneContext.deviceIdentifier)")
    }
    blueberryZone.onExit = { zoneContext in
        print("Exited near range of tag 'DevOffice'. DeviceIdentifier: \(zoneContext.deviceIdentifier)")
    }

    blueberryZone.onContextChange = { contexts in
        print("Now in range of \(contexts.count) contexts")
    }
    // ... etc. You can define as many zones as you need.
    // Start proximity observation
    //self.observe.startObserving([blueberryZone])
    self.proximityObserver.startObserving([blueberryZone])
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.tabBarController?.title = "HOME"
}

/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destination.
    // Pass the selected object to the new view controller.
}
*/

}

I'm getting this crash while fetching NearbyTags from Cloud

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] PID: 457, TID: 60500, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0 Backtrace: 4 libobjc.A.dylib 0x000000019c7476f4 + 56 5 CoreMotion 0x00000001a2e91638 CoreMotion + 292408 6 CoreMotion 0x00000001a2e91b68 CoreMotion + 293736 7 CoreMotion 0x00000001a2e91a78 CoreMotion + 293496 8 CoreMotion 0x00000001a2ebf8a8 CoreMotion + 481448 9 CoreMotion 0x00000001a2ebf8ec CoreMotion + 481516 10 CoreFoundation 0x000000019d4d378c + 28 11 CoreFoundation 0x000000019d4d3074 + 276 12 CoreFoundation 0x000000019d4ce368 + 2276 13 CoreFoundation 0x000000019d4cd764 CFRunLoopRunSpecific + 452 14 CoreFoundation 0x000000019d4ce498 CFRunLoopRun + 84 15 CoreMotion 0x00000001a2ebf280 CoreMotion + 479872 16 libsystem_pthread.dylib 0x000000019d14d920 + 132 17 libsystem_pthread.dylib 0x000000019d14d87c _pthread_start + 48 18 libsystem_pthread.dylib 0x000000019d155dcc thread_start + 4 2019-05-20 16:53:40.004753+0530 Critik[457:60500] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] PID: 457, TID: 60500, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0 Backtrace: 4 libobjc.A.dylib 0x000000019c7476f4 + 56 5 CoreMotion 0x00000001a2e91638 CoreMotion + 292408 6 CoreMotion 0x00000001a2e91b68 CoreMotion + 293736 7 CoreMotion 0x00000001a2e91a78 CoreMotion + 293496 8 CoreMotion 0x00000001a2ebf8a8 CoreMotion + 481448 9 CoreMotion 0x00000001a2ebf8ec CoreMotion + 481516 10 CoreFoundation 0x000000019d4d378c + 28 11 CoreFoundation 0x000000019d4d3074 + 276 12 CoreFoundation 0x000000019d4ce368 + 2276 13 CoreFoundation 0x000000019d4cd764 CFRunLoopRunSpecific + 452 14 CoreFoundation 0x000000019d4ce498 CFRunLoopRun + 84 15 CoreMotion 0x00000001a2ebf280 CoreMotion + 479872 16 libsystem_pthread.dylib 0x000000019d14d920 + 132 17 libsystem_pthread.dylib 0x000000019d14d87c _pthread_start + 48 18 libsystem_pthread.dylib 0x000000019d155dcc thread_start + 4

vinodgleecus commented 5 years ago

can anyone please respond to this?

chwastek commented 5 years ago

hey @vinodgleecus firstly sorry for not responding for so long! secondly: could you share bit more?

Regards

vinodgleecus commented 5 years ago

yes it happens every time pod 'EstimoteProximitySDK','~> 1.2.1' no, I didn't any logs
yes Am 100% Sure

divrt-anvesht commented 4 years ago

I too have same problem "Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]" in my current App Store app. @Estimote could you please fix this issue ASAP. I am using EstimoteProximitySDK (1.4.1) in my app. This weird bug in iPhone X and later devices making app stuck for a while....