我正在开发一个Parse应用程序,我需要在登录后获得用户publish_actions
的许可。我正在使用PFFacebookUtilsV4框架。我试过了
[[PFFacebookUtils facebookLoginManager] logInWithPublishPermissions:@[@"publish_actions"] fromViewController:controller handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (result.isCancelled)
{
NSLog(@"permission denied");
}else{
NSLog(@"permission granted");
}
}];
这会弹出safari浏览器,但不会加载任何内容。我上面的代码做错了什么或可能是什么问题?
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:nil];
return [[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
plist
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>FacebookAppID</key>
<string>XYZ</string>
答案 0 :(得分:0)
在Swift我有这个:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let configuration = ParseClientConfiguration {
$0.applicationId = "MY_APP_ID"
$0.server = "MY_SERVER_URL"
}
Parse.initialize(with: configuration)
PFFacebookUtils.initializeFacebook(applicationLaunchOptions: launchOptions)
return true
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBSDKAppEvents.activateApp()
}
您可以这样配置:
<key>FacebookAppID</key>
<string>YOU_APP_ID</string>
<key>FacebookDisplayName</key>
<string>YOUR_DISPLAY_NAME</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
要使用权限登录,我使用了这个:
PFFacebookUtils.logInInBackground(withReadPermissions: ["public_profile"]) { (user: PFUser?, error: Error?) in
if error == nil, let ruser = user {
print("WORKS")
}
print("EPIC FAIL")
}
答案 1 :(得分:0)
试试这个!简单的解决方案:)此外,如果您的应用未经Facebook批准,用户应具有测试人员或管理员角色来测试您的应用。 https://developers.facebook.com/docs/apps/test-users
异常域名
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>FacebookAppID</key>
<string>xxxFACEBOOKIDxxx</string>
<key>FacebookDisplayName</key>
<string>App Name</string>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fbxxxFACEBOOKIDxxx</string> // should have URL types
</array>
</dict>
</array>