From 9796071d4344c917b47ce77374053230076f5b91 Mon Sep 17 00:00:00 2001 From: Nikolay Demyankov Date: Tue, 30 Aug 2016 10:21:48 +0200 Subject: [PATCH] Added getVersionInfo method to iOS. --- src/ios/HCPPlugin.h | 4 ++-- src/ios/HCPPlugin.m | 8 ++++++-- src/ios/Utils/NSBundle+HCPExtension.h | 7 +++++++ src/ios/Utils/NSBundle+HCPExtension.m | 8 +++++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/ios/HCPPlugin.h b/src/ios/HCPPlugin.h index daed64f1..13592bc0 100644 --- a/src/ios/HCPPlugin.h +++ b/src/ios/HCPPlugin.h @@ -67,10 +67,10 @@ - (void)jsIsUpdateAvailableForInstallation:(CDVInvokedUrlCommand *)command; /** - * Get the name of the current version. + * Get information about app and web versions. * * @param command command with which the method is called */ -- (void)jsGetCurrentVersion:(CDVInvokedUrlCommand *)command; +- (void)jsGetVersionInfo:(CDVInvokedUrlCommand *)command; @end diff --git a/src/ios/HCPPlugin.m b/src/ios/HCPPlugin.m index c07d292b..1fea42a2 100644 --- a/src/ios/HCPPlugin.m +++ b/src/ios/HCPPlugin.m @@ -787,8 +787,12 @@ - (void)jsIsUpdateAvailableForInstallation:(CDVInvokedUrlCommand *)command { [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; } -- (void)jsGetCurrentVersion:(CDVInvokedUrlCommand *)command { - NSDictionary *data = @{@"currentVersion": _pluginInternalPrefs.currentReleaseVersionName}; +- (void)jsGetVersionInfo:(CDVInvokedUrlCommand *)command { + NSDictionary *data = @{@"currentWebVersion": _pluginInternalPrefs.currentReleaseVersionName, + @"readyToInstallWebVersion": _pluginInternalPrefs.readyForInstallationReleaseVersionName, + @"previousWebVersion": _pluginInternalPrefs.previousReleaseVersionName, + @"appVersion": [NSBundle applicationVersionName], + @"buildVersion": [NSBundle applicationBuildVersion]}; CDVPluginResult *result = [CDVPluginResult pluginResultWithActionName:nil data:data error:nil]; [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; diff --git a/src/ios/Utils/NSBundle+HCPExtension.h b/src/ios/Utils/NSBundle+HCPExtension.h index 33d13525..65d3192d 100644 --- a/src/ios/Utils/NSBundle+HCPExtension.h +++ b/src/ios/Utils/NSBundle+HCPExtension.h @@ -18,6 +18,13 @@ */ + (NSString *)applicationBuildVersion; +/** + * Getter for application's version name. + * + * @return version name of the app + */ ++ (NSString *)applicationVersionName; + /** * Path to the www folder in the application bundle. * diff --git a/src/ios/Utils/NSBundle+HCPExtension.m b/src/ios/Utils/NSBundle+HCPExtension.m index 12ae96d5..69901a88 100644 --- a/src/ios/Utils/NSBundle+HCPExtension.m +++ b/src/ios/Utils/NSBundle+HCPExtension.m @@ -17,7 +17,13 @@ @implementation NSBundle (HCPExtension) + (NSString *)applicationBuildVersion { NSBundle *mainBundle = [NSBundle mainBundle]; - return [mainBundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; + return [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]; +} + ++ (NSString *)applicationVersionName { + NSBundle *mainBundle = [NSBundle mainBundle]; + + return [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; } + (NSString *)pathToWwwFolder {