Parse-sdk-ios-osx: Local Data Store - Cannot query for pinned objects when using Parse-server

Created on 8 Feb 2016  路  3Comments  路  Source: parse-community/Parse-SDK-iOS-OSX

I have recently started using Parse-Server and have migrated my Parse App, now when I try to use Parse Local DataStore I receive the following error:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Method requires Pinning enabled.'

This is the code that produces the error:

PFQuery *query = [PFQuery queryWithClassName:@"MY_CLASS_NAME"];
[query fromPinWithName:@"PIN_NAME"];
[query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {

If I initialise parse the old way by calling:

[Parse setApplicationId:@"APP_ID" clientKey:@"KEY"];
Then Local DataStore works fine, but if I initialise Parse the new way then I get the error:

[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {

 configuration.applicationId = @"APP_ID";
 configuration.clientKey = @"KEY";
 configuration.server = @"SERVER";

 }]];

I am calling [Parse enableLocalDatastore];before Parse is being initialised, I've tried calling it after as well just to be sure.

Thanks for your time, hope you can help

Most helpful comment

Hey @shaynos, if you are using configuration with initialization - you need to enable a local datastore slightly differently. Add the following line into the configuration block to enable it:

configuration.localDatastoreEnabled = YES;

All 3 comments

Hey @shaynos, if you are using configuration with initialization - you need to enable a local datastore slightly differently. Add the following line into the configuration block to enable it:

configuration.localDatastoreEnabled = YES;

I was getting a similar issue as shaynos, however, after changing to the suggested fix I am now getting a different error. @nlutsenko, are you or someone else able to help?

in applicationDidFinishLaunching I have this:

let configuration = ParseClientConfiguration {
    $0.applicationId = Constants.Parse.appId
    $0.clientKey = Constants.Parse.clientId
    $0.server = Constants.Parse.server
    $0.localDatastoreEnabled = true
}
Parse.initializeWithConfiguration(configuration)

I am then trying to do:

let query = PFQuery(className: className)
query.getFirstObjectInBackgroundWithBlock { object, error in }

This doesn't return an error or any objects as it crashes with the following message:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to change an objectId to one that's already known to the OfflineStore.'

Any ideas what's happening? Thanks in advance

I am having the same issue and tried to follow the guidance above. I still get the error message:

'NSInternalInconsistencyException', reason: 'Method not allowed when Pinning is enabled.'

This is my code:

let parseConfig = ParseClientConfiguration {
            $0.applicationId = "someAppId"
            $0.clientKey = "someMasterKey"
            $0.server = "http://somehost:1337/parse"
            $0.isLocalDatastoreEnabled = true

 }
        Parse.enableLocalDatastore()
        Parse.initialize(with: parseConfig)

Is there any other code or config required?

In my PFQuery, I have:

let query = PFQuery(className: name)
query.fromLocalDatastore()
query.cachePolicy = .cacheElseNetwork
Was this page helpful?
0 / 5 - 0 ratings