Error 3840 with self hosted parse server 2.2.9 and iOS sdk 1.13 - parse-server

In my app delegate, I call
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = #"MYAPPKEY";
configuration.clientKey = #"";
configuration.server = #"DOMAIN/parse";
}]];
// test parse
PFObject *gameScore = [PFObject objectWithClassName:#"TestObject"];
gameScore[#"foo"] = #"bar";
[gameScore saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
// The object has been saved.
NSLog(#"parse is working");
} else {
// There was a problem, check error.description
NSLog(#"parse is not working: %#",error);
}
}];
and I get the following 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.}
I get the error from any call to parse.
My server works well with the Android SDK and the JS SDK, but I keep getting this error on iOS. I've added my domain to the App Transport Security Settings.

You can not leave the clientKey empty. The parse server does not use clientKey any more but it still crashes when its null.
configuration.clientKey = #"47b6r78tb3ynf907ynoe";

You should try with adding a / after the
configuration.server = #"DOMAIN/parse";
so it looks like
configuration.server = #"DOMAIN/parse/";

Related

Core data disable journal_mode don't work

I want to disable the journal mode in my core data app.
This is the code:
- (NSPersistentContainer *)persistentContainer {
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
#synchronized (self) {
if (_persistentContainer == nil) {
_persistentContainer = [[NSPersistentContainer alloc] initWithName:#"My_App"];
NSURL *url = [[self applicationFilesDirectory] URLByAppendingPathComponent:#"My_App.sqlite"];
NSPersistentStoreDescription *description=[[NSPersistentStoreDescription alloc]initWithURL:url];
NSMutableDictionary *pragmaOptions=[NSMutableDictionary dictionary];
[pragmaOptions setObject:#"DELETE" forKey:#"journal_mode"];
[description setOption:pragmaOptions forKey:#"NSQlitePragmaOptions"];
_persistentContainer.persistentStoreDescriptions=#[description];
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
if (error != nil) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
NSLog(#"Unresolved error %#, %#", error, error.userInfo);
abort();
}
}];
}
}
return _persistentContainer;}
I also verified with this:
NSArray *descriptionArray=[_persistentContainer persistentStoreDescriptions];
NSPersistentStoreDescription * description=[descriptionArray objectAtIndex:0];
NSLog(#"%#",description.options);
and the result of NSLog is:
{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSQlitePragmaOptions = {
"journal_mode" = DELETE;
};
but when I restart my app I always find in the application directory all the three file My_App.sqlite, My_App.sqlite-shm and My_App.sqlite-wal.
Why doesn't it work?

can't load Safari contentBlocker. because can't access app group's NSUserDefault

I am making iOS 9 Safari AdBlocker app.
I am using the module of AdBlockPlusSafari.
App works good on simulator.
But when try to run it on device(iPhone6), it fails to reload contentBlocker.
[SFContentBlockerManager
reloadContentBlockerWithIdentifier:self.contentBlockerIdentifier
completionHandler:^(NSError *error) {
if (error) {
NSLog(#"Error in reloadContentBlocker: %#", error);
}
dispatch_async(dispatch_get_main_queue(), ^{
wSelf.reloading = NO;
[wSelf checkActivatedFlag];
if (completion) {
completion(error);
}
});
}];
it gives error
Error Domain=ContentBlockerErrorDomain Code=3 "(null)"
It caused by accessing the values in NSUserDefault (App Group).
- (instancetype)init
{
if (self = [super init])
{
_bundleName = [[[[[NSBundle mainBundle] bundleIdentifier] componentsSeparatedByString:#"."] subarrayWithRange:NSMakeRange(0, 2)] componentsJoinedByString:#"."];
NSString *group = [NSString stringWithFormat:#"group.%#.%#", _bundleName, #"AdBlockerPro"];
NSLog(#"Group name: %#", group);
_adblockProDetails = [[NSUserDefaults alloc] initWithSuiteName:group];
[_adblockProDetails registerDefaults:
#{ AdblockProActivated: #NO,
AdblockProEnabled: #YES
}];
_enabled = [_adblockProDetails boolForKey:AdblockProEnabled];
_activated = [_adblockProDetails boolForKey:AdblockProActivated];
}
return self;
}
The App Group name in host app and safari extension is same.
But in Safari extension, when app accesses the setting in NSUserDefault, it gives me the error.
In Project setting/Capabilities, I did all for App Group. In app id, it involves app group name exactly.
This happens on only device. On simulator, it works good. I can't find the reason of this error.
Please help me if you are experienced this.
Looking forward to your help.
I found the reason myself.
I have put something (NSMutableDictionary) in app group container and did something to write file to extension bundle.
It is prohibited by Apple.
So I deleted all from AdBlockManager (interacts with app group) except flag variables (Boolean type).
And I proceeded the file management using NSFileManager.
http://www.atomicbird.com/blog/sharing-with-app-extensions
Finally, app extension is working for me on device.
Good luck!

Suppressing Core Data errors from addPersistentStoreWithType:

I have a custom NSIncrementalStore. If there's a problem adding it, the error is automatically logged to the console.
The problem is that the options can contain sensitive data that I obviously don't want logged to the console.
I presume the error is logged by Core Data, which I don't really need, since I already have an NSError argument that I can use appropriately.
For example:
#implementation FakeStore
- (BOOL)loadMetadata:(NSError **)error {
*error = [NSError errorWithDomain:#"faildomain" code:531 userInfo:nil];
return NO;
}
#end
Attempt at adding the store:
[NSPersistentStoreCoordinator registerStoreClass:[FakeStore class] forStoreType:#"FakeStore"];
...
NSDictionary *options = #{#"option": #"sensitivedata"};
NSError *error;
[persistentCoordinator addPersistentStoreWithType:#"FakeStore" configuration:nil URL:storeUrl
options:options error:&error];
The error that is automatically logged to the console:
CoreData: error: -addPersistentStoreWithType:FakeStore configuration:(null) URL:<URL> options:{
option = sensitivedata;
} ... returned error Error Domain=faildomain Code=531 "The operation couldn’t be completed. (faildomain error 531.)" with userInfo dictionary {
}
A workaround is that the sensitive data shouldn't be passed into the options for my store, but it shouldn't be necessary.
Is there anyway to suppress this error?
well you can't turn it off but you should be able to redirect it. Bummer.. needs private API .. is that an option for you?
https://www.google.de/search?client=safari&rls=en&q=_NSSetLogCStringFunction&ie=UTF-8&oe=UTF-8&gfe_rd=cr&ei=uUKdVe-QN4nj8wfl9AE
tried the first link and found it still worked!
if private API is no option: no (and Id file a bug :D)

Google Drive API - list specific files in a specific folder using Objective-C

I'm working on a Google Drive integration for iOS and I've hit a snag—I need to check for the existence of a file in a folder, but I keep getting a "500 Internal Error" response no matter how I seem to put together the request. I think this should be legit:
// self.directoryDriveFile.identifier is a valid folder identifier retrieved on previous request
GTLQueryDrive *query = [GTLQueryDrive queryForChildrenListWithFolderId:self.directoryDriveFile.identifier];
// add query to specify the file we're interested in (works in Java version...)
query.q = [NSString stringWithFormat:#"title='%#' and trashed=false",
ZTCloudSyncLockFileName];
// stopping in debugger shows query.q: title='sync.lock' and trashed=false
// fire off request
[self.driveService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFileList *files,
NSError *error) {
if (error == nil) {
if ([files.items count] > 0) {
self.foundLockfile = YES;
} else {
self.foundLockfile = NO;
}
} else {
DLog(#"An error occurred loading lockfile request: %#", error);
[self bailWithError:error performCleanup:NO];
}
}];
When the query is executed, it always ends up in error, with the following unfortunately sparse error information:
Error Domain=com.google.GTLJSONRPC
ErrorDomain Code=500 "The operation couldn’t be completed. (Internal Error)"
UserInfo=0x99c4660 {
error=Internal Error,
GTLStructuredError=GTLErrorObject 0x99c4360: {
message:"Internal Error" code:500 data:[1]},
NSLocalizedFailureReason=(Internal Error)}
I've also tried the following more basic query, specifying a parents clause, but I end up with the same unfortunately spare error object shown above:
GTLQueryDrive *altQuery = [GTLQueryDrive queryForFilesList];
altQuery.q = [NSString stringWithFormat:#"title='%#' and trashed=false and '%#' in parents",
ZTCloudSyncLockFileName,
self.directoryDriveFile.identifier];
That, too, should work, but also produces a 500 error.
Additional information: tested the following while working on this:
Check for folder in directory root—OK
Create folder in directory root—OK
Check for file named sync.lock in directory root—OK
-(void)fetchGoogleDriveFileListWithfolderId:(NSString *)folderId
:(void (^)(NSMutableArray *, NSError*))completionBlock
{
GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q =[NSString stringWithFormat:#"'%#' in parents and trashed=false", folderId];
GTLServiceTicket *ticketListing = [self.driveService
executeQuery:query completionHandler:^(GTLServiceTicket *ticket,GTLDriveFileList *files, NSError *error)
{
NSMutableArray *mainArray=[[NSMutableArray alloc]init];
if (error == nil)
{
completionBlock(files.items,nill);
}
else
{
NSLog(#"An error occurred: %#", error);
completionBlock(nil,error);
}
}];
}
You can use above method for fetch the folder contents.
Here folderId is
“root” (Main Drive)
“sharedWithMe” for shared folder
GTLDrivefile identifier value

Posting comment to YouTube with GData ObjC client library fails

I'm trying to implement commenting on YouTube videos with the gdata-objectivec-client library, using the code snippet posted in this thread; copy follows:
- (void)addCommentTitle:(NSString *)commentTitle
text:(NSString *)commentContent
toVideo:(GDataEntryYouTubeVideo *)entry {
GDataComment *commentObj = [entry comment];
GDataFeedLink *feedLink = [commentObj feedLink];
NSURL *feedURL = [feedLink URL];
if (feedURL) {
// fetch the comment feed for the video
GDataServiceGoogleYouTube *service = [self youTubeService];
[service fetchFeedWithURL:feedURL
completionHandler:^(GDataServiceTicket *ticket, GDataFeedBase *commentFeed, NSError *error) {
// callback
//
// insert a new comment into the comment feed
if (error == nil) {
GDataEntryYouTubeComment *newCommentEntry = [GDataEntryYouTubeComment commentEntry];
[newCommentEntry setTitleWithString:commentTitle];
[newCommentEntry setContentWithString:commentContent];
NSURL *postURL = [[commentFeed postLink] URL];
[service fetchEntryByInsertingEntry:newCommentEntry
forFeedURL:postURL
completionHandler:^(GDataServiceTicket *ticket, GDataEntryBase *entry, NSError *error) {
// callback
if (error == nil) {
// succeeded
}
}];
}
}];
}
}
but I always get the following exception:
*** Assertion failure in -[GDataObject setContentStringValue:](), XXXXXXXX/GData/BaseClasses/GDataObject.m:2353
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'GDataEntryYouTubeComment setting undeclared content value'
Luckily enough, I managed to make this go away by adding a new call before the comment contents are set:
GDataEntryYouTubeComment* newCommentEntry = [GDataEntryYouTubeComment commentEntry];
[newCommentEntry addContentValueDeclaration]; // <--- this method does the trick
[newCommentEntry setTitleWithString:commentTitle];
[newCommentEntry setContentStringValue:commentContent];
but it's still not OK as the request now bounces back from the server with this error:
serviceBase:<GDataServiceGoogleYouTube: 0x7a73eb0>
objectFetcher:GTMHTTPFetcher 0x7c75b20 (https://gdata.youtube.com/feeds/api/videos/XXXXXXXXXX/comments)
failedWithStatus:400
data:<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>ParseException</code><internalReason>[Line 2, Column 514, element entry] No converter for type class java.lang.Void</internalReason></error><error><domain>GData</domain><code>missingConverter</code><internalReason>No converter for type class java.lang.Void</internalReason></error></errors>
Has anyone else run into this issue? Is this an error on my side or Google's side?
Turns out the above code is correct, in my code I misspelled
[newCommentEntry setContentWithString:commentContent];
and used
[newCommentEntry setContentStringValue:commentContent];
instead. Now it works fine.