Skip to content

Commit

Permalink
Fixes #18: Installs now properly applied on iOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Mar 6, 2021
1 parent 7022e05 commit 8cb9a72
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ios/Plugin/CodePush.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,26 @@ - (void)notifyApplicationReady:(CAPPluginCall *)call {
[call resolve];
}

-(NSNumber *) getNumber:(CAPPluginCall *)call field:(NSString *)field defaultValue:(NSNumber *)defaultValue {
id idVal = [call.options objectForKey:field];
if(![idVal isKindOfClass:[NSNumber class]]) {
return defaultValue;
}
NSNumber *value = (NSNumber *)idVal;
if(value == nil) {
return defaultValue;
}
return value;
}

- (void)install:(CAPPluginCall *)call {
NSString* location = [self getString:call field:@"startLocation" defaultValue:nil];
NSString* installModeString = [self getString:call field:@"installMode" defaultValue:IMMEDIATE];
NSString* minimumBackgroundDurationString = [self getString:call field:@"minimumBackgroundDuration" defaultValue:0];
NSNumber* installMode = [self getNumber:call field:@"installMode" defaultValue:IMMEDIATE];
NSNumber* minimumBackgroundDuration = [self getNumber:call field:@"minimumBackgroundDuration" defaultValue:0];

InstallOptions* options = [[InstallOptions alloc] init];
[options setInstallMode:[installModeString intValue]];
[options setMinimumBackgroundDuration:[minimumBackgroundDurationString intValue]];
[options setInstallMode:[installMode intValue]];
[options setMinimumBackgroundDuration:[minimumBackgroundDuration intValue]];

if ([options installMode] == IMMEDIATE) {
if (nil == location) {
Expand Down

0 comments on commit 8cb9a72

Please sign in to comment.