summaryrefslogtreecommitdiff
path: root/plugins/uk.co.whiteoctober.cordova.appversion/src/ios/AppVersion.m
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-07-03 08:31:13 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-07-03 08:31:13 -0400
commite0ba24662b631394b4076ac39fad970447879f8f (patch)
treea376c7822232389cefe6995d9b06e2ccc527f7f6 /plugins/uk.co.whiteoctober.cordova.appversion/src/ios/AppVersion.m
parent1c137f2b75a18dfc3bfd8b729c58e43974c9ead2 (diff)
Added plugin that picks up version from config.xml and displays in app
Diffstat (limited to 'plugins/uk.co.whiteoctober.cordova.appversion/src/ios/AppVersion.m')
-rw-r--r--plugins/uk.co.whiteoctober.cordova.appversion/src/ios/AppVersion.m47
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/uk.co.whiteoctober.cordova.appversion/src/ios/AppVersion.m b/plugins/uk.co.whiteoctober.cordova.appversion/src/ios/AppVersion.m
new file mode 100644
index 00000000..a73c78f9
--- /dev/null
+++ b/plugins/uk.co.whiteoctober.cordova.appversion/src/ios/AppVersion.m
@@ -0,0 +1,47 @@
+#import "AppVersion.h"
+#import <Cordova/CDVPluginResult.h>
+
+@implementation AppVersion
+
+- (void)getAppName : (CDVInvokedUrlCommand *)command
+{
+ NSString * callbackId = command.callbackId;
+ NSString * version =[[[NSBundle mainBundle]infoDictionary]objectForKey :@"CFBundleDisplayName"];
+ CDVPluginResult * pluginResult =[CDVPluginResult resultWithStatus : CDVCommandStatus_OK messageAsString : version];
+ [self.commandDelegate sendPluginResult : pluginResult callbackId : callbackId];
+}
+
+- (void)getPackageName:(CDVInvokedUrlCommand*)command
+{
+ NSString* callbackId = command.callbackId;
+ NSString* packageName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:packageName];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
+}
+
+- (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 = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
+}
+
+- (void)getVersionCode:(CDVInvokedUrlCommand*)command
+{
+ NSString* callbackId = command.callbackId;
+ NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
+}
+
+@end