Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
Fix for #73. Configure callback is now called.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikDemyankov committed Dec 28, 2015
1 parent 0c2b539 commit 6f92675
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/ios/HCPPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -630,17 +630,26 @@ - (void)jsConfigure:(CDVInvokedUrlCommand *)command {
return;
}

id configureArguments = command.arguments[0];
NSError *error = nil;
id options = [NSJSONSerialization JSONObjectWithContentsFromString:command.arguments[0] error:&error];
NSDictionary *options;
if ([configureArguments isKindOfClass:[NSString class]]) {
options = [NSJSONSerialization JSONObjectWithContentsFromString:configureArguments error:&error];
} else {
options = configureArguments;
}

if (error) {
[self.commandDelegate sendPluginResult:nil callbackId:command.callbackId];
CDVPluginResult *pluginResult = [CDVPluginResult pluginResultWithActionName:nil applicationConfig:nil error:error];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
return;
}

[_pluginXmlConfig mergeOptionsFromJS:options];
// TODO: store them somewhere?

[self.commandDelegate sendPluginResult:nil callbackId:command.callbackId];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)jsFetchUpdate:(CDVInvokedUrlCommand *)command {
Expand Down
1 change: 1 addition & 0 deletions src/ios/JS/CDVPluginResult+HCPEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ + (CDVPluginResult *)pluginResultWithActionName:(NSString *)action applicationCo
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonObject options:kNilOptions error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

// TODO: should be moved to an [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
}

Expand Down

0 comments on commit 6f92675

Please sign in to comment.