【问题标题】:Parse Setup at AppdelageAppdelage 的解析设置
【发布时间】:2016-12-15 13:12:16
【问题描述】:

您好,我正在尝试设置 Parse。有人告诉我这个步骤对吗?

这段代码放在哪里?

PFAnalytics.trackAppOpenedWithLaunchOptions(nil)

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

我认为它会帮助其他新的 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)
    }

【问题讨论】:

    标签: swift parse-platform parse-server


    【解决方案1】:

    您的appdelegate 很好!不幸的是,parse-server 目前不支持PFAnalytics。所以这行不通。

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

    我注意到你在你的问题上标记了 swift。您的设置是客观的 C,但它的快速不同。

    斯威夫特 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。

    【讨论】:

    • 太棒了,非常感谢它对我帮助很大:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-26
    相关资源
    最近更新 更多