Ios Swift Error 3840 when trying to point client to Parse server on Heroku
I am having a problem when trying to point my client to the Parse Server. I am using Heroku with mongolab. I have tried two different ways to do this in swift, but I still get the same error. These are the two ways I have done it:
let configuration = ParseClientConfiguration(block: {
(ParseMutableClientConfiguration) -> Void in
ParseMutableClientConfiguration.applicationId = "appID"
ParseMutableClientConfiguration.clientKey = "appMasterKey"
ParseMutableClientConfiguration.server = "https://MyAppName.herokuapp.com/parse"
})
Parse.initializeWithConfiguration(configuration);
and I also tried:
let configuration = ParseClientConfiguration {
$0.applicationId = "appID"
$0.clientKey = "appMasterKey"
$0.server = "https://MyAppName.herokuapp.com/parse"
}
Parse.initializeWithConfiguration(configuration)
Both ways I still get error code of 3840 "JSON text did not start with array or object and option to allow fragments not set."
2016-03-24 11:20:31.538 ClockIn[4668:676920] Warning: A long-running operation is being executed on the main thread.
Break on warnBlockingOperationOnMainThread() to debug.
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.}
Either of these work if I use https://api.parse.com/1/ for the server, but does not work if I try to use my own server. Does anyone know why this is happening, or is it just broken when using iOS and swift?
try : $0.server = "https://MyAppName.herokuapp.com/parse/"
Add this to Exception Domains in info.plist
<key>herokuapp.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
@flovilmart I tried this buy I get the same result. @andreiurzica When I tried to enter this into the info.plist it just crashed.
how did you configure parse-server?
This appears to be a client SDK issue unrelated to Parse Server. Please look for the relevant repository on GitHub for this SDK and consider opening an issue there.
A list of Parse's open source repositories is available at parseplatform.github.io
You may use Server Fault for questions about managing Parse Server.
For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.
I got it working. I wasn't setting up my Parse Server correctly. I was following the migration guide, but I didn't get the index.js file set up correctly. I found that the steps from the answer to this stackoverflow helped out a lot. http://stackoverflow.com/questions/35389389/how-can-i-host-my-own-parse-server-on-heroku-using-mongodb I figured I would post these here incase anyone else has the same issue.
I'm still seeing this error with iOS SDK 1.13 and Parse server 2.2.9. The server works fine from js and from Android, but I get this error from any call from iOS: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=XXXXXXXXX {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
I'm seeing this error as well. @rendragon83 What exactly did you fix in your index.js file? @oproulx Did you resolve this in the end?
Hey @craiggrummitt I think I ended up reinstalling the server completely (created a new instance). I think something was corrupt with my first installation.
What I discovered was that this obscure error message is indicating that the data being returned from Heroku wasn't correctly formatted JSON, in my case I discovered this was because heroku was returning an error (I had used my login credentials for Mongo in the Mongo database URL, rather than the mongo database credentials). I discovered the nature of this error by typing heroku logs in terminal.