问题
I'm trying to get the Facebook SDK to work. The only goal I'm trying to achieve is to verify activations, I'm not using the login, sharing. etc. Every install step is complete but when I check the analytics it's not logging data. Does anyone have an idea as to why?
If needed, my install process is outlined below:
1) I downloaded the SDK yesterday. I dragged the bolts and core files into my project navigator then, in the Build Settings, I've added the path to the framework:
"/Users/Dave/Documents/Misc/FacebookSDKs-iOS"
2) I setup my app on the Facebook Developer page with my App ID and Bundle ID:
3) On that same page I have single sign-on enabled:
4) Under "Build Phases", in the "Link Binary With Libraries" section, I see the right files:
5) In my info.plist file I also have all the code it requested:
<key>FacebookAppID</key>
<string>(my_FB-ID_IsHere)</string>
<key>FacebookDisplayName</key>
<string>(DisplayNameIsHere)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
</dict>
</dict>
6) A picture of my info.plist after code was added:
7) In the app delegate file I believe I have the correct Swift code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
let settings = UIUserNotificationSettings(forTypes: [.Alert], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
return true
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
//Other code...
func applicationDidBecomeActive(application: UIApplication) {
FBSDKAppEvents.activateApp()
}
8) Because I'm using Swift, I followed this tutorial and added a "Bridge-Header.h" file with this code:
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#endif /* Bridging_Header_h */
So that's it... right? Where's my data!? This is all I see:
回答1:
Figured out that their was a small error in my info.plist:
I had added the "FB" prefix to my app ID (for example: "FB1234567"). This is necessary for the top ID but not the bottom:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1234567</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1234567</string>
<key>FacebookDisplayName</key>
<string>MyAppName</string>
来源:https://stackoverflow.com/questions/37059797/not-receiving-data-from-facebook-ios-sdk