iOS App Extension将PFUser currentUser设置为nil [英] iOS App Extension has PFUser currentUser set to nil

查看:95
本文介绍了iOS App Extension将PFUser currentUser设置为nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启用了Parse的iOS 8应用,并且我正在尝试启用Share Extension.我已经完全按照 https://www上所说的做了.parse.com/docs/ios/guide#extensions ,但在我的应用扩展程序中,[PFUser currentUser]设置为nil(在我的应用程序中不为nil),而[PFInstallation currentInstallation]设置为新实例,而不是现有安装. App Extension与我的应用进行通信似乎存在问题.

I have a Parse-enabled iOS 8 app and I'm trying to enable Share Extension. I've done exactly what it says at https://www.parse.com/docs/ios/guide#extensions but in my app extension, [PFUser currentUser] is set to nil (while it is not nil in my app), and [PFInstallation currentInstallation] is set to a new instance instead of my existing installation. There seems to be a problem with App Extension communicating with my app.

在解析"文档中,它明确指出:

In the Parse docs it clearly states:

如果您已有使用Parse SDK的应用程序,则当用户升级到 您最新的应用程序版本(启用了数据共享),Parse SDK 将自动移动主应用程序的本地持久数据(本地 应用程式的资料储存库,目前的PFUser,目前的PFInstallation等) 沙盒容器到共享容器.

If you have an existing app using the Parse SDK, when users upgrade to your latest app version (with data sharing enabled), the Parse SDK will automatically move the main app's local persistent data (Local Datastore, current PFUser, current PFInstallation, etc) from the app's sandbox container to the shared container.

我已启用具有相同ID的钥匙串共享和应用组,并添加了适当的代码.为什么我的扩展名中仍以nil作为当前用户?我正在使用最新的Parse iOS SDK(1.7.4).

I have enabled Keychain Sharing and App Groups with the same IDs, and added the appropriate code. Why am I still getting nil as the current user in my extension? I am on the latest Parse iOS SDK (1.7.4).

推荐答案

发现了问题:

我没有在应用扩展中启用本地数据存储.必须同时在应用本身应用扩展中启用数据存储.在初始化Parse之前和数据共享代码(enableDataSharingWithApplicationGroupIdentifier:containingApplication:)之后添加[Parse enableLocalDatastore];解决了我的问题.

I wasn't enabling local datastore in the app extension. Data store must be enabled both in the app itself and the app extension. Adding [Parse enableLocalDatastore]; before initializing Parse and after data sharing code (enableDataSharingWithApplicationGroupIdentifier:containingApplication:) solved my problem.

这篇关于iOS App Extension将PFUser currentUser设置为nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆