gpt4 book ai didi

swift - Appdelage 的解析设置

转载 作者:行者123 更新时间:2023-11-28 16:00:24 27 4
gpt4 key购买 nike

您好,我正在尝试设置 Parse。谁能告诉我这个步骤正确吗?

这段代码放在哪里?

PFAnalytics.trackAppOpenedWithLaunchOptions(无)

有人检查我的初始化步骤吗?

我认为它会帮助其他新的 Parse 用户。

谢谢

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

//Hidden statusbar
UIApplication.shared.isStatusBarHidden = true

// Override point for customization after application launch.
Parse.enableLocalDatastore()
Parse.setLogLevel(PFLogLevel.info);

//Initialize Pare
let config = ParseClientConfiguration(block: {
(ParseMutableClientConfiguration) -> Void in
//back4app
ParseMutableClientConfiguration.applicationId = "xxxxxxxxx";
ParseMutableClientConfiguration.clientKey = "xxxxxxxxx";
//Parse LiveQuery Server
ParseMutableClientConfiguration.server = "https://xxxxxxxxx/";



});


Parse.initialize(with: config);


//Initialize Facebook
PFFacebookUtils.initializeFacebook(applicationLaunchOptions: launchOptions)

PFTwitterUtils.initializeWithConsumerKey("xxxxxx", consumerSecret: "xxxxxx")


PFUser.enableAutomaticUser()
buildUserInterface()

// color of window
window?.backgroundColor = UIColor.white

//Set Fabric
Fabric.with([Crashlytics.self])

//register ParseSubclass
configureParse()

let userNotificationTypes: UIUserNotificationType = [.alert, .badge, .sound]
let settings = UIUserNotificationSettings(types: userNotificationTypes, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()


return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

最佳答案

您的 appdelegate 没问题!不幸的是,解析服务器目前不支持 PFAnalytics。所以那是行不通的。

您将不得不使用其他工具,例如 Google、fabric 等。

我注意到您对您的问题进行了快速标记。您的设置是 objective C,但与 swift 不同。

swift 3

// Init Parse
let configuration = ParseClientConfiguration {
$0.applicationId = "XXX"
$0.clientKey = "XXX"
$0.server = "XXX"
$0.isLocalDatastoreEnabled = true

}
Parse.initialize(with: configuration)

PFFacebookUtils.initializeFacebook(applicationLaunchOptions: launchOptions);
PFConfig.getInBackground{(config: PFConfig?, error: Error?) -> Void in
if error == nil {
//print(config?["OfflineMode"])
}
}

您还需要在 didFinishLaunchingWithOptions 之外添加 FBSDKApplicationDelegate

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL!, sourceApplication: sourceApplication, annotation: annotation)
}

另外不要忘记为您使用的选择性社交平台或分析添加框架。在那种情况下,我建议使用 CocoaPods 作为依赖管理器。

适用于 Swift 和 Objective C。

关于swift - Appdelage 的解析设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41165054/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com