My today widget takes between 0 and 5 seconds to show up after pulling down the notification center. As soon as I move up my notification center a bit, my widget disappears again.
Once the widget is visible, everything works fine.
What am I missing?
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
if (self.locationManager.respondsToSelector(Selector("requestWhenInUseAuthorization"))){
self.locationManager.requestWhenInUseAuthorization()
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
self.locationManager.startUpdatingLocation()
imageViewCheck.layer.cornerRadius = 5.0
self.getLocation()
}
func getLocation() -> Bool{
var test = self.locationManager.location
if test != currentLocation {
currentLocation = test
return true
} else {
return false
}
}
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
var newLocation = self.getLocation()
if (newLocation) {
completionHandler(NCUpdateResult.NewData)
} else {
completionHandler(NCUpdateResult.NoData)
}
}