在Appdelage解析设置

时间:2016-12-15 13:12:17

标签: swift parse-platform parse-server

嗨,我正在尝试设置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)
    }

1 个答案:

答案 0 :(得分:1)

你的appdelegate没问题!不幸的是,解析服务器目前还不支持PFAnalytics。这样就行不通了。

您必须使用其他工具,例如Google,fabric等。

我注意到你迅速标记了你的问题。你的设置是客观的C,但快速与众不同。

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"])
            }
        }

您还需要在FBSDKApplicationDelegate

之外添加didFinishLaunchingWithOptions
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&目标C。