forked from microsoft/react-native-code-push
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
171 additions
and
141 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#import "CodePush.h" | ||
|
||
static NSString *const LastDeploymentReportKey = @"CODE_PUSH_LAST_DEPLOYMENT_REPORT"; | ||
static NSString *const DeploymentKeyKey = @"deploymentKey"; | ||
static NSString *const LabelKey = @"label"; | ||
|
||
@implementation CodePushStatusReport | ||
|
||
+ (NSString *)getDeploymentKeyFromStatusReportIdentifier:(NSString *)statusReportIdentifier | ||
{ | ||
return [[statusReportIdentifier componentsSeparatedByString:@":"] firstObject]; | ||
} | ||
|
||
+ (NSString *)getPackageStatusReportIdentifier:(NSDictionary *)package | ||
{ | ||
// Because deploymentKeys can be dynamically switched, we use a | ||
// combination of the deploymentKey and label as the packageIdentifier. | ||
NSString *deploymentKey = [package objectForKey:DeploymentKeyKey]; | ||
NSString *label = [package objectForKey:LabelKey]; | ||
if (deploymentKey && label) { | ||
return [[deploymentKey stringByAppendingString:@":"] stringByAppendingString:label]; | ||
} else { | ||
return nil; | ||
} | ||
} | ||
|
||
+ (NSString *)getPreviousStatusReportIdentifier | ||
{ | ||
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults]; | ||
NSString *sentStatusReportIdentifier = [preferences objectForKey:LastDeploymentReportKey]; | ||
return sentStatusReportIdentifier; | ||
} | ||
|
||
+ (NSString *)getVersionLabelFromStatusReportIdentifier:(NSString *)statusReportIdentifier | ||
{ | ||
return [[statusReportIdentifier componentsSeparatedByString:@":"] lastObject]; | ||
} | ||
|
||
+ (BOOL)isStatusReportIdentifierCodePushLabel:(NSString *)statusReportIdentifier | ||
{ | ||
return statusReportIdentifier != nil && [statusReportIdentifier containsString:@":"]; | ||
} | ||
|
||
+ (void)recordDeploymentStatusReported:(NSString *)appVersionOrPackageIdentifier | ||
{ | ||
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults]; | ||
[preferences setValue:appVersionOrPackageIdentifier forKey:LastDeploymentReportKey]; | ||
[preferences synchronize]; | ||
} | ||
|
||
@end |
Oops, something went wrong.