0
votes

I just set up an application on Parse-Server (Heroku/MLab) to use with an iOS app (in objective C). Refering to my few previous experiences of the kind, I think it should work. But when I try to save an object from my iOS app to the Parse-Server, it fails.

Here is the initialization code, in AppDelegate.m :

[Parse initializeWithConfiguration:
 [ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
    configuration.applicationId = @"AAAABBBCCCCXXXXYYYY333344445555";
    configuration.clientKey = @"9999999888888887777777wwwwwwHHHHHHzzzzZZZ";
    configuration.localDatastoreEnabled = @"https://myownapp.herokuapp.com/parse";
}]];

Here is the code I use to save the object inside the iOS app:

PFObject *myObject = [PFObject objectWithClassName:@"MyCollectionName"];
// name and membersString are NSString objects previously defined.
myObject[@"name"] = name; 
myObject[@"members"] = membersString;
[myObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
    if (succeeded) {
        NSLog(@"all is working fine!");
    } else {
        NSLog(@"Error:\n%@",error);
    }
}];

Here is the error I get in the Xcode debugging console:

Error Domain=Parse Code=100 "A server with the specified hostname could not be found." 
UserInfo={code=100, error=A server with the specified hostname could not be found., 
NSLocalizedDescription=A server with the specified hostname could not be found., 
temporary=1, originalError=Error Domain=NSURLErrorDomain 
Code=-1003 "A server with the specified hostname could not be found." 
UserInfo={NSUnderlyingError=0x1c0844140 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" 
UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}}, 
NSErrorFailingURLStringKey=https://api.parse.com/1/classes/MyCollectionName, 
NSErrorFailingURLKey=https://api.parse.com/1/classes/MyCollectionName, 
_kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, 
NSLocalizedDescription=A server with the specified hostname could not be found.}, 
NSUnderlyingError=0x1c0848b20 {Error Domain=NSURLErrorDomain 
Code=-1003 "A server with the specified hostname could not be found." 
UserInfo={NSUnderlyingError=0x1c0844140 {Error Domain=kCFErrorDomainCFNetwork 
Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}}, 
NSErrorFailingURLStringKey=https://api.parse.com/1/classes/MyCollectionName, 
NSErrorFailingURLKey=https://api.parse.com/1/classes/MyCollectionName, _kCFStreamErrorDomainKey=12, 
_kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}}}

I have set a proper name for my server: https://myownapp.herokuapp.com/.

I do not quite understand why I see : https://api.parse.com appear in the error message. This may be what is wrong? But I do not really know what to do to change it. I think I have done all what is necessary both on the app side and on the server side; but I am obviously missing something.

If anyone has an idea about the solution, please let me know. That will be much appreciated.

1
https://api.parse.com/ is not reachabale - dahiya_boy
Well you are right, I can also read that. But what can I do about it? I am not setting this "api.parse.com" anywhere in my code. I can only read this in the error message. - Michel
How do you initialize your parse connection in your Appdelegate? - WaleedAmmari
I just edited the post to add this information. Please take a look, I hope you can see what is wrong there. Thank you. - Michel

1 Answers

1
votes

You probably need to initialized the SDK correctly.

configuration.localDatastoreEnabled = @"https://myownapp.herokuapp.com/parse";

This should probably be:

configuration.server = @"https://myownapp.herokuapp.com/parse";
configuration.localDatastoreEnabled = true;