Created
January 27, 2015 16:09
-
-
Save samsonasu/22dea9e6a600d448f5be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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