Skip to content

Instantly share code, notes, and snippets.

@samsonasu
Created January 27, 2015 16:09
Show Gist options
  • Save samsonasu/22dea9e6a600d448f5be to your computer and use it in GitHub Desktop.
Save samsonasu/22dea9e6a600d448f5be to your computer and use it in GitHub Desktop.
#import "AppVersion.h"
#import <Cordova/CDVPluginResult.h>
@implementation AppVersion
- (void)getVersionNumber:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
if (version == nil) {
NSLog(@"CFBundleShortVersionString was nil, attempting CFBundleVersion");
version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
if (version == nil) {
NSLog(@"CFBundleVersion was also nil, giving up");
// not calling error callback here to maintain backward compatibility
}
}
CDVPluginResult* pluginResult = nil;
NSString* javaScript = nil;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
javaScript = [pluginResult toSuccessCallbackString:callbackId];
[self writeJavascript:javaScript];
}
- (void)getInternalVersion:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
CDVPluginResult* pluginResult = nil;
NSString* javaScript = nil;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
javaScript = [pluginResult toSuccessCallbackString:callbackId];
[self writeJavascript:javaScript];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment