swift - Urban Airship swift

标签 swift urbanairship.com

我正在尝试将 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/

相关文章:

Android "Urban Airship"- GCM - 未找到 Activity 设备 token

iphone - 将应用内购买(订阅)添加到 iOS 应用 - 无法测试 ("Invalid product ID")

android - 关闭应用程序时不会收到通知

ios - XCode 6.3.1 启动图像源不适用于 Assets 目录

swift - CLLocationManager 只工作一次

swift - 导航后退按钮返回 View Controller

ios - 快速对象映射

swift - 无法使用 Alamofire 4 调用非函数类型 '((UInt) -> Data?)!' 的值

php - Urban Airship - 将 PUSH 发送到 1 个特定设备(设备 token )

ios - 我们可以以及如何使用 Urbanairship for iOS app Enterprise Distribution?