Appdelage 的解析设置
Parse Setup at Appdelage
您好,我正在尝试设置 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 等
我注意到您在问题中标记了 swift。您的设置是 objective C,但 swift 不同。
Swift 3
// Init Parse
let configuration = ParseClientConfiguration {
[=10=].applicationId = "XXX"
[=10=].clientKey = "XXX"
[=10=].server = "XXX"
[=10=].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。
您好,我正在尝试设置 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 等
我注意到您在问题中标记了 swift。您的设置是 objective C,但 swift 不同。
Swift 3
// Init Parse
let configuration = ParseClientConfiguration {
[=10=].applicationId = "XXX"
[=10=].clientKey = "XXX"
[=10=].server = "XXX"
[=10=].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。