If an application is configured to connect to different instances on Parse server using separate application id/secrets, what is the best way to verify if application has connected to correct instance on Parse. Basically it's about pulling down some sort of meta data before actually trying to Write/Read objects stored in backend.
I am currently working with iOS SDK and Parse.h/PFObject.h/PFQuery.h
doesn't contain any such information.
Something that I figured out if querying for the application Id and try to match it against predefined values for an environment. Is there a better way to do that ?
Have a look at PFConfig. You can set configuration parameters in each Parse instance that are unique.
Here is a quick example of how to use it:
NSLog(@"Getting the latest config...");
[PFConfig getConfigInBackgroundWithBlock:^(PFConfig *config, NSError *error) {
if (!error) {
NSLog(@"Yay! Config was fetched from the server.");
} else {
NSLog(@"Failed to fetch. Using Cached Config.");
config = [PFConfig currentConfig];
}
NSString *welcomeMessage = config[@"welcomeMessage"];
if (!welcomeMessage) {
NSLog(@"Falling back to default message.");
welcomeMessage = @"Welcome!";
}
NSLog(@"Welcome Messsage = %@", welcomeMessage);
}];