错误域=NSCocoaErrorDomain 代码=3840

Error Domain=NSCocoaErrorDomain Code=3840

我知道很多其他人也有同样的问题,并且有很多相同的问题 subject/title。但是其中 none 解决了我的问题。

我对云代码和 Facebook 登录使用解析。但是,由于解析关闭,我将代码移至 back4app。

这是我移动到我自己的服务器后的 Parse 初始化:

[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
    configuration.applicationId = @"ParseApplicationId";
    configuration.clientKey = @"ParseClientKey";
    configuration.server = @"https://parseapi.back4app.com";
}]];

当我尝试使用 PFLogInViewController 登录时,在 Facebook 登录后调用委托方法:

- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error

我收到此错误:

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

使用PFLogInViewController登录与我的云代码无关,因为它完全由 Parse SDK 处理。

此错误的可能原因是什么。如果您需要任何进一步的代码片段,我也可以提供。

谢谢

好的,我解决了。在我的例子中,我的解析初始化应该是这样的:

[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
    configuration.applicationId = ParseApplicationId;
    configuration.clientKey = ParseClientKey;
    configuration.server = @"https://parseapi.back4app.com";
}]];

ParseApplicationIdParseClientKey 是常量,我错误地作为字符串传递。

如果有人使用自己的服务器托管解析云服务器,请记住您的服务器不应阻止 graph.facebook.com。我的本地服务器允许 facebook.com 但仍然阻止 graph.facebook.com,并且花了一天多的时间才找出解决方案。

此外,您不能像以前那样保存 PFUser,您可能必须将 useMasterKey 添加为 true。这些与我的问题无关,但我想知道是否有人可能会遇到这些问题。