- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我一直在尝试集成 Facebook 登录和 Parse,以便在登录时创建一个新的 PFUser。我创建了一个 Facebook 登录按钮,当我按下它时,会出现标准的 Facebook 登录/请求权限屏幕。当我接受登录时,我被重定向回初始屏幕,日志显示用户已取消 Facebook 登录。当我在 Parse 网站上查看我的数据时,没有 PFUser。
据我所知,我已经按照 Parse ( https://parse.com/docs/ios/guide#users ) 和 Facebook ( https://developers.facebook.com/docs/ios/getting-started ) 制定的确切说明进行操作。我正在使用 XCode 6.3.2。我在 Cocoapods 中添加了集成的 Parse (ParseFacebookUtilsV4 v1.7 & ParseUI v1.1) 和 Facebook (FBSDKCoreKit v4.2 &FBSDKLoginKit v4.2),并链接了以下库:
libsqlite3.dylib
libz.dylib
Accounts.framework
AudioToolbox.framework
CFNetwork.framework
CoreGraphics.framework
CoreLocation.framework
CoreLocation.framework
MobileCoreService.framework
QuartzCore.framework
Security.framework
Social.framework
StoreKit.framework
SystemConfiguration.framework
libPods-xxx.a (being the name of my project)
我的代码如下:
//Appdelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
//--------------------------------------
// MARK: - UIApplicationDelegate
//--------------------------------------
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Parse.setApplicationId("xxxxxxxx",
clientKey: "xxxxxxxxxx")
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
func application( application: UIApplication,
openURL url: NSURL,
sourceApplication: String,
annotation: AnyObject?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
//Facebook analytics
func applicationDidBecomeActive(application: UIApplication!) {
FBSDKAppEvents.activateApp()
}
以及放置登录名的 View Controller :
//OnboardingRootViewController.swift
import Foundation
import UIKit
class OnboardingRootViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func fbLoginClick(sender: AnyObject) {
var permissions = ["public_profile", "email", "user_likes"]
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) {
(user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
println("User signed up and logged in through Facebook!")
} else {
println("User logged in through Facebook!")
}
} else {
println("Uh oh. The user cancelled the Facebook login.")
}
}
}
}
那么,有人能帮忙吗?同样,当调用 IBAction fbLoginClick 时,Facebook 登录至少看起来有效,但是“呃哦。用户取消了 Facebook 登录。”消息显示在日志中,并且没有在 Parse 中创建新的 PFUser。我已经看到多个其他类似的问题,但没有一个有任何真正的答案,所以我相信这个问题的答案会受到很多人的欢迎,特别是因为这是使用由 Parse 和 Facebook 创建的登录教程中显示的确切代码!
编辑:如果没有人能够提供帮助,我仍然希望得到以下方面的帮助:有人告诉我应该检查 loginInBackgroundWithReadPermissions 返回的错误消息,遗憾的是没有进一步的解释。这个人只是指“呃哦。用户取消了 Facebook 登录”。消息,或者是否可以通过 NSError 检索任何信息?
编辑#2:我添加了以下代码行以查看 NSError 返回的内容: println("写入失败: (error?.localizedDescription)")
并在日志中得到如下信息: 呃哦。用户取消了 Facebook 登录。 写入失败:无
所以我想这并没有真正让我更进一步......
编辑 #3:说真的,我会支付 10 美元给任何能帮助我的人
最佳答案
如果您正确设置框架并遵循 Parse 的 Facebook 设置指南 (https://parse.com/docs/ios/guide#users-facebook-users) 的步骤,此代码将起作用。确保您的语法与我的函数相同,并尝试删除未包含在下面的任何不必要的代码。
AppDelegate.swift
import UIKit
import CoreData
import Parse
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//X's replace my actual Parse information
Parse.setApplicationId("XXXXXXXXXXXXXXXXXXXXXX", clientKey: "XXXXXXXXXXXXXXXXXXXXXX")
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
FBSDKAppEvents.activateApp()
}
/*
func application(application: UIApplication, url: NSURL, sourceApplication: NSString, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication as String,
annotation: annotation)
}*/
func application(application: UIApplication,
openURL url: NSURL,
sourceApplication: String?,
annotation: AnyObject?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
self.saveContext()
}
ViewController.swift
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
let permissions = [ "email","user_birthday", "public_profile", "user_friends"]
@IBAction func loginButtonPressed(sender: AnyObject) {
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) {
(user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
println("User signed up and logged in through Facebook!")
} else {
println("User logged in through Facebook!")
}
} else {
println("Uh oh. The user cancelled the Facebook login.")
}
}
}
}
@IBAction 用于我放置在 Main.storyboard 空白 View Controller 中心的简单 UIButton
Objective-C 桥接头文件:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <Parse/Parse.h>
希望这能解决您的问题!
关于ios - 解析 : Facebook login not creating new PFUser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30830855/
嗨,我试图在亚马逊服务托管的计算机上远程登录。这是ubuntu 64位机器。 一开始,我能够使用客户端、远程桌面连接 (RDP) 登录计算机,并保持默认端口 (-1),而对于命令行,我使用 putty
我已将 Jenkins 设置为使用 Unix 用户/组数据库安全性,但除了运行 Jenkins 服务的用户之外,我无法使用我创建的任何用户登录。通过 ssh 或 su 登录服务器可以工作,但是当我尝试
我想通过 power shell 使用以下命令在 azure 中创建一个新的资源组: New-AzureRmResourceGroup - Name name -Location "WesternEu
我已经部署了由 spring boot 应用程序使用 oauth2 生成的 war 文件,以便使用 Azure 应用服务进行单点登录(仅限 https)。 当我浏览主页时,主页会加载一个登录按钮。单击
我已经部署了由 spring boot 应用程序使用 oauth2 生成的 war 文件,以便使用 Azure 应用服务进行单点登录(仅限 https)。 当我浏览主页时,主页会加载一个登录按钮。单击
我尝试按照一些 django 教程来创建登录名,但我一直在获取 ImportError at /login No module named login 我的文件结构是: -src -log
在我的 Spring 项目中,我将注销目标 url 设置为“/login?logout”以显示登录页面并显示消息“您现在已注销”。 在 Spring Security 配置中,我这样做了: @Over
我目前正在尝试为我在带有 Ubuntu 的虚拟机上运行的实际本地网页创建一个简单的登录页面。 我创建了 LoginPage.html在位置 /var/www/html . 然后 HTML 文件调用 l
我有两个安全区域,我为其提供基于表单的登录。 /用户 /admin 以下按预期工作: 访问 protected 资源时重定向到登录页面 当凭据为假时使用 ?error 参数重定向到登录页面 根据定义的
我有一个脚本,我通常用来同步AG登录。但是,我需要使用SQL凭据和密码将其实现为自动运行。有人知道我如何调整下面的脚本以使用SQL登录和密码吗?
更新 下面的 Flask 重定向(响应代码 302)似乎作为对 _dash-update-component 的响应传递。要求: b'\nRedirecting...\nRedirecting...\
这是我第一次使用 Django 登录模板,但遇到了问题。它一直说 login 不是一个有效的 View 函数,但我在我的用户应用程序的 urls.py 中定义了它: 不知道我做错了什么。 主 urls
我不是专业程序员,所以请原谅任何愚蠢的错误——我正在做一些研究,我正在尝试使用 Selenium 登录数据库以搜索大约 1000 个术语。 我有两个问题:1. 重定向到组织登录页面后如何使用 Sele
我正在使用 flutter,我想在我的应用程序中实现使用 Instagram 登录。所以我关注这个tutorial用于 Instagram 登录, 我成功登录但未获取用户详细信息,它正在打开重定向 U
每当我以访客身份重定向时,我都会收到错误消息: Missing required parameters for [Route: login] [URI: {locale}/login]. 但是当我登录
我已开始使用 Azure Pipelines 和 GitHub 支持的帐户并创建了我的第一个组织。我在该组织中没有任何项目。我在 portal.azure.com 上也没有任何订阅。我想使用 Azur
它给出错误:找不到“登录”的反向。 “登录”不是有效的 View 函数或模式名称。 网址.py urlpatterns = [ path('admin/', admin.site.urls),
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 2年前关闭。 Improve t
我需要一个自定义的 Facebook 登录按钮。 fb:login-button 的 medium、large 等解决方案不是我需要的。我知道 FB TOS。我的按钮将非常相似。 如何将我的按钮转换为
Spring 版: 2.5.6 SEC01 Spring 安全版本: 3.0.0 RC1 我正在尝试将 Spring Security 与 Spring MVC 应用程序集成。安全部分主要基于 Spr
我是一名优秀的程序员,十分优秀!