我正在尝试将UrbanAirship集成到我的项目中,但我收到以下错误:
2016-08-25 16:26:23.898 Fiber [7758:368753] [E] __52 + [UAirship handleAppDidFinishLaunchingNotification:] _ block_invoke [Line 320]请确保在申请前同步调用[UAirship takeOff]:didFinishLaunchingWithOptions:return < / p>
任何帮助解决这个问题都将非常感谢!
我的申请代表如下:
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
}
答案 0 :(得分:1)
我还没有在我之前使用过Urban Airship SDK,但是在发布错误消息之前,你发布的关键位似乎是&#34;在应用程序之前同步调用:didFinishLaunchingWithOptions:返回&#34;。
我猜想发生的事情是你在UAirship上调用takeOff方法,但是在该方法完成之前,didFinishLaunchingMethod正在返回;很可能因为它是在另一个线程中处理的。)
尝试使用&#34; dispatch_async&#34;强制在主线程上运行takeOff方法。然后传入主队列,例如:
dispatch_async(dispatch_get_main_queue(), {
UAirship.takeOff(config)
})
尝试一下,希望能解决这个问题。