我们在Parse.com FaceBook登录时遇到过这种情况。以下是步骤:
- 从AppStore下载并安装应用程序
- 用户使用Facebook帐户登录
通常,在_Installation集合中有一个新行,在_User集合中也有一个。但是,有时会丢失_Installation条目,而存在用户的_User条目。
我们的应用程序需要用户和他/她的设备之间的逻辑链接,以实现每个用户一台设备的策略。
当用户(由_user条目表示)由于不存在相应的_Installation条目而无法链接时,应用程序将中断。我们只在iOS 7上观察到了这个错误。
你能检查一下这是否真的是Parse SDK中的一个错误吗?如果是,什么时候可以修复?
我还没有遇到你描述的确切问题,但我在使用Parse和Swift时遇到了一些类似的实例,其中将创建_User
和_Installation
对象,但它们不会链接。我所做的是在我的应用程序主页(登录屏幕后的第一个屏幕)的ViewController
的ViewDidLoad
功能中添加一个功能,以确保两者都已设置并链接。希望能有所帮助!
override func viewDidLoad() {
if ((PFUser.currentUser()) != nil) {
var current: PFInstallation = PFInstallation.currentInstallation()
current["userId"] = PFUser.currentUser()
current.saveEventually()
}
}
编辑:在我的项目中,我需要添加上面的代码,因为当有人第一次注册我的应用时,下面的代码并不总是将_User
对象保存到我的AppDelegate
文件中的_Installation
对象
func application(application: UIApplication!, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData!) {
let currentInstallation:PFInstallation = PFInstallation.currentInstallation()
currentInstallation.setDeviceTokenFromData(deviceToken)
if ((PFUser.currentUser()) != nil) {
currentInstallation["userId"] = PFUser.currentUser()
}
currentInstallation.saveInBackgroundWithTarget(nil, selector: nil)
}