我是新开发者,我目前正在制作我的第一个应用。 有时当我尝试打开应用程序时,图标会变暗,但没有任何反应,整个手机会短暂地变得无法响应。我的猜测是这发生在app delegate中。我不确定发生了什么,但我认为我应该使用盛大的中央调度。
这是我在app delegate中的代码,
import UIKit
import Firebase
import FirebaseMessaging
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//Facebook SharedInstance FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
//Firebase Database
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
//Onesignal PushNotifications
_ = OneSignal(launchOptions: launchOptions, appId: "3b2b4845-0b6a-4e92-892f-254c2cf51da8", handleNotification: nil)
_ = OneSignal(launchOptions: launchOptions, appId: "3b2b4845-0b6a-4e92-892f-254c2cf51da8", handleNotification: { (message, additionalData, isActive) in
NSLog("OneSignal Notification opened:\nMessage: %@", message)
if additionalData != nil {
NSLog("additionalData: %@", additionalData)
// Check for and read any custom values you added to the notification
// This done with the "Additonal Data" section the dashbaord.
// OR setting the 'data' field on our REST API.
if let customKey = additionalData["customKey"] as! String? {
NSLog("customKey: %@", customKey)
}
}
}, autoRegister: true)
print("didFinishLaunchingWithOptions launchOptions")
return true
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
print("application")
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

是否有可能,这与app delegate无关?
如果它在app delegate中如何使用GCD来完成这项工作
答案 0 :(得分:0)
删除
import FirebaseMessaging
和
FIRDatabase.database().persistenceEnabled = true
来自AppDeleget的并尝试运行它