我在Mavic Air上的DJIFlightControllerParamIsFlying键上设置了一个监听器。永远不会被召唤。
让flyingKey = DJIFlightControllerKey(param:DJIFlightControllerParamIsFlying)
DJISDKManager.keyManager()?.startListeningForChanges(on: flyingKey!, withListener: self, andUpdate: { (oldValue: DJIKeyedValue?, newValue: DJIKeyedValue?) in
Logger.sharedLogger.log(message: "Received flying status change", event: "Notice", fileName: #file,line: #line,funcName: #function)
})
我还需要做些什么来启用该消息吗?
谢谢,
答案 0 :(得分:0)
您应该检查keyManager是否为nil:
guard let km = DJISDKManager.keyManager() else {
// handle error
return
}
km.startListeningForChanges(on: flyingKey!, withListener: self, andUpdate: { (oldValue: DJIKeyedValue?, newValue: DJIKeyedValue?) in
Logger.sharedLogger.log(message: "Received flying status change", event: "Notice", fileName: #file,line: #line,funcName: #function)
})
如果在注册前调用此键,则KeyManager可能返回nil。