首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“PFFacebookUitils.Type”没有名为“initializeFacebook”的成员

“PFFacebookUitils.Type”没有名为“initializeFacebook”的成员
EN

Stack Overflow用户
提问于 2015-05-21 15:21:00
回答 1查看 237关注 0票数 0

我正在安装一个facebook登录来解析。https://www.parse.com/docs/ios/guide#users-facebook-users上的解析网站说:

您还需要进行两处代码更改。首先,在初始化Parse SDK之后,将以下代码添加到应用程序中:didFinishLaunchingWithOptions: method。

代码语言:javascript
复制
// Import this header into your Swift bridge header   file
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>

// AppDelegate.swift
func application(application: UIApplication,      didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  Parse.setApplicationId("parseAppId",    clientKey:"parseClientKey")
  PFFacebookUtils.initializeFacebookWithLaunchOptions(launch    Options)
}

AppDelegate.swift中的parsestaterproject表示:

代码语言:javascript
复制
// If you are using Facebook, uncomment and add your   FacebookAppID to your bundle's plist as
    // described here:    https://developers.facebook.com/docs/getting-   started/facebook-sdk-for-ios/
    // Uncomment the line inside ParseStartProject-   Bridging-Header and the following line here:


    //PFFacebookUtils.initializeFacebook()

我已经尝试了两个*.initializeFacebook选项,但都给出了相同的错误:'PFFacebookUtils.Type‘没有名为'initializeFacebook ...’的成员。

我的代码是:

代码语言:javascript
复制
//  AppDelegate.swift
//
//  Copyright 2011-present Parse Inc. All rights   reserved.
//

import UIKit
import Bolts
import Parse

// If you want to use any of the UI components, uncomment this line
// import ParseUI

// If you want to use Crash Reporting - uncomment this line
// import ParseCrashReporting

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    //--------------------------------------
    // MARK: - UIApplicationDelegate
    //--------------------------------------

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject:     AnyObject]?) -> Bool {

        Parse.enableLocalDatastore()

        //         **********************************************************    ******************
        // Uncomment this line if you want to enable Crash Reporting
        // ParseCrashReporting.enable()

            Parse.setApplicationId("RETRACTED_FOR_SECURITY", clientKey: "RETRACTED_FOR_SECURITY")

  // var pushSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: .Alert, categories: nil)

    // application.registerForRemoteNotifications(pushSettings)
    // application.registerForRemoteNotifications()



    //
    // If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as
    // described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/
    // Uncomment the line inside ParseStartProject-Bridging-Header and the following line here:


    //PFFacebookUtils.initializeFacebook()

        PFFacebookUtils.initializeFacebookWithLaunchOptions(launchOptions)
    // ****************************************************************************

    PFUser.enableAutomaticUser()

    let defaultACL = PFACL();

    // If you would like all objects to be private by default, remove this line.
    defaultACL.setPublicReadAccess(true)

    PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser:true)

    if application.applicationState != UIApplicationState.Background {
        // Track an app open here if we launch with a push, unless
        // "content_available" was used to trigger a background push (introduced in iOS 7).
        // In that case, we skip tracking here to avoid double counting the app-open.

        let preBackgroundPush = !application.respondsToSelector("backgroundRefreshStatus")
        let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
        var noPushPayload = false;
        if let options = launchOptions {
            noPushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil;
        }
        if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
            PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
        }
    }
    if application.respondsToSelector("registerUserNotificationSettings:") {
        let userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
        let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()
    } else {
        let types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound
        application.registerForRemoteNotificationTypes(types)
    }

    return true
}

//--------------------------------------
// MARK: Push Notifications
//--------------------------------------

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    let installation = PFInstallation.currentInstallation()
    installation.setDeviceTokenFromData(deviceToken)
    installation.saveInBackground()

    PFPush.subscribeToChannelInBackground("", block: { (succeeded: Bool, error: NSError?) -> Void in
        if succeeded {
            println("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.");
        } else {
            println("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.", error)
        }
    })
}

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    if error.code == 3010 {
        println("Push notifications are not supported in the iOS Simulator.")
    } else {
        println("application:didFailToRegisterForRemoteNotificationsWithError: %@", error)
    }
}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    PFPush.handlePush(userInfo)
    if application.applicationState == UIApplicationState.Inactive {
        PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
    }
}

///////////////////////////////////////////////////////////
// Uncomment this method if you want to use Push Notifications with Background App Refresh
///////////////////////////////////////////////////////////
// func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
//     if application.applicationState == UIApplicationState.Inactive {
//         PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
//     }
// }

//--------------------------------------
// MARK: Facebook SDK Integration
//--------------------------------------

///////////////////////////////////////////////////////////
// Uncomment this method if you are using Facebook
///////////////////////////////////////////////////////////
// func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
//     return FBAppCall.handleOpenURL(url, sourceApplication:sourceApplication, session:PFFacebookUtils.session())
// }

func application(application: UIApplication,
    openURL url: NSURL,
    sourceApplication: String?,
    annotation: AnyObject?) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application,
            openURL: url,
            sourceApplication: sourceApplication,
            annotation: annotation)
}

func applicationDidBecomeActive(application: UIApplication) {
    FBSDKAppEvents.activateApp()
}


}

我的app-bridging h文件是:

代码语言:javascript
复制
    //  ParseStarterProject-Bridging-Header.h
    //
    //  Copyright 2011-present Parse Inc. All rights     reserved.
//

#define ParseStarterProject_Bridging_Header_h
#define ParseStarterProject_Bridging_Header_h

// If you are using Facebook, uncomment this line to     get automatic import of the header inside your project.
//#import <ParseFacebookUtils/PFFacebookUtils.h>


#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>


#endif
EN

回答 1

Stack Overflow用户

发布于 2015-05-22 01:47:45

我找到了。应该是: PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions).但请注意,虽然这解决了这个错误,但上面的代码仍然导致另一个错误,我将在另一个线程中发布该错误:链接器命令失败,退出代码为1(使用-v查看调用)-

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30367061

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档