我正在尝试将 UrbanAirship 集成到我的项目中,但出现以下错误:
2016-08-25 16:26:23.898 Fibre[7758:368753] [E] __52+[UAirship handleAppDidFinishLaunchingNotification:]_block_invoke [Line 320] Please ensure that [UAirship takeOff] is called synchronously before application:didFinishLaunchingWithOptions: returns
如果能帮助解决这个问题,我们将不胜感激!
我的申请委托(delegate)如下:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
let configuration = ParseClientConfiguration { (configuration) -> Void in
configuration.applicationId = "******"
configuration.clientKey = "*****"
configuration.server = "https://*****.herokuapp.com/parse"
}
Parse.initializeWithConfiguration(configuration)
let config: UAConfig = UAConfig.defaultConfig()
UAirship.takeOff(config)
return true
}
最佳答案
我自己之前没有使用过 Urban Airship SDK,但是您发布的错误消息似乎是“在应用程序之前同步调用:didFinishLaunchingWithOptions:返回”。
我猜测发生的事情是您在 UAirship 上调用 takeOff 方法,但 didFinishLaunchingMethod 在该方法完成之前返回;很可能是因为它正在另一个线程中处理)。
尝试使用“dispatch_async”强制在主线程上运行 takeOff 方法,然后传入主队列,例如:
dispatch_async(dispatch_get_main_queue(), {
UAirship.takeOff(config)
})
尝试一下,希望能解决问题。
关于swift - Urban Airship swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39149248/