Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
Added getVersionInfo method to iOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikDemyankov committed Aug 30, 2016
1 parent eb5f1ed commit 9796071
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ios/HCPPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions src/ios/HCPPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
7 changes: 7 additions & 0 deletions src/ios/Utils/NSBundle+HCPExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 7 additions & 1 deletion src/ios/Utils/NSBundle+HCPExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9796071

Please sign in to comment.