通知ターゲットをバックグラウンドスレッドで起動させようとしています。ドキュメントは、ターゲットが通知がエンキューされたトレッド上で呼び出されることを主張しています。IOS、DisplaceQueue.globalでラップされたNotificationQueueコールが起動しない
バックグラウンドで実行されるDispatchQueue内のエンキューをラップすると、ターゲットは呼び出されません。 DispatchQueueを削除すると、もちろんメインスレッドでターゲットが呼び出されます。
for aLocation in locations {
// add it to the queue
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {
let notify = Notification(name: MyLocationManager.queueName(), object:aLocation)
NotificationQueue.default.enqueue(notify,
postingStyle: NotificationQueue.PostingStyle.asap,
coalesceMask:NotificationQueue.NotificationCoalescing(rawValue: 0),
forModes: nil)
}
}