When you are setting up a PhoneGap project, you see the following:
<
As a small tweak to @CWSpear's awesome answer, I also wanted to grab the Build:
Grab the Build and Version:
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSString* build = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
Throw them into a Dict:
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[NSString stringWithString:version] forKey:@"version"];
[dict setObject:[NSString stringWithString:build] forKey:@"build"];
Modify the pluginResult to return the new Dict:
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
Cordova.exec:
cordova.exec(function(response){
console.log(response.build);
console.log(response.version);
}, null, "MyCDVPlugin", "getVersionNumber", []);
I don't know enough about objective C to return it as two args in the JS cordova.exec callback function, otherwise that would probably be the most straight forward.
Steve