forked from microsoft/react-native-code-push
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodePush.h
More file actions
158 lines (116 loc) · 5.09 KB
/
CodePush.h
File metadata and controls
158 lines (116 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#import <Foundation/Foundation.h>
@interface CodePush : NSObject
+ (NSURL *)binaryBundleURL;
/*
* This method is used to retrieve the URL for the most recent
* version of the JavaScript bundle. This could be either the
* bundle that was packaged with the app binary, or the bundle
* that was downloaded as part of a CodePush update. The value returned
* should be used to "bootstrap" the React Native bridge.
*
* This method assumes that your JS bundle is named "main.jsbundle"
* and therefore, if it isn't, you should use either the bundleURLForResource:
* or bundleURLForResource:withExtension: methods to override that behavior.
*/
+ (NSURL *)bundleURL;
+ (NSURL *)bundleURLForResource:(NSString *)resourceName;
+ (NSURL *)bundleURLForResource:(NSString *)resourceName
withExtension:(NSString *)resourceExtension;
+ (NSString *)getApplicationSupportDirectory;
/*
* This methods allows dynamically setting the app's
* deployment key, in addition to setting it via
* the Info.plist file's CodePushDeploymentKey setting.
*/
+ (void)setDeploymentKey:(NSString *)deploymentKey;
// The below methods are only used during tests.
+ (BOOL)isUsingTestConfiguration;
+ (void)setUsingTestConfiguration:(BOOL)shouldUseTestConfiguration;
+ (void)clearUpdates;
@end
@interface CodePushConfig : NSObject
@property (readonly) NSString *appVersion;
@property (readonly) NSString *buildVersion;
@property (readonly) NSDictionary *configuration;
@property (copy) NSString *deploymentKey;
@property (copy) NSString *serverURL;
+ (instancetype)current;
@end
@interface CodePushDownloadHandler : NSObject <NSURLConnectionDelegate>
@property (strong) NSOutputStream *outputFileStream;
@property long long expectedContentLength;
@property long long receivedContentLength;
@property dispatch_queue_t operationQueue;
@property (copy) void (^progressCallback)(long long, long long);
@property (copy) void (^doneCallback)(BOOL);
@property (copy) void (^failCallback)(NSError *err);
- (id)init:(NSString *)downloadFilePath
operationQueue:(dispatch_queue_t)operationQueue
progressCallback:(void (^)(long long, long long))progressCallback
doneCallback:(void (^)(BOOL))doneCallback
failCallback:(void (^)(NSError *err))failCallback;
- (void)download:(NSString*)url;
@end
@interface CodePushErrorUtils : NSObject
+ (NSError *)errorWithMessage:(NSString *)errorMessage;
+ (BOOL)isCodePushError:(NSError *)error;
@end
@interface CodePushPackage : NSObject
+ (void)downloadPackage:(NSDictionary *)updatePackage
expectedBundleFileName:(NSString *)expectedBundleFileName
operationQueue:(dispatch_queue_t)operationQueue
progressCallback:(void (^)(long long, long long))progressCallback
doneCallback:(void (^)())doneCallback
failCallback:(void (^)(NSError *err))failCallback;
+ (NSString *)getBinaryAssetsPath;
+ (NSDictionary *)getCurrentPackage:(NSError **)error;
+ (NSDictionary *)getPreviousPackage:(NSError **)error;
+ (NSString *)getCurrentPackageFolderPath:(NSError **)error;
+ (NSString *)getCurrentPackageBundlePath:(NSError **)error;
+ (NSString *)getCurrentPackageHash:(NSError **)error;
+ (NSDictionary *)getPackage:(NSString *)packageHash
error:(NSError **)error;
+ (NSString *)getPackageFolderPath:(NSString *)packageHash;
+ (void)installPackage:(NSDictionary *)updatePackage
removePendingUpdate:(BOOL)removePendingUpdate
error:(NSError **)error;
+ (void)rollbackPackage;
// The below methods are only used during tests.
+ (void)clearUpdates;
+ (void)downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl;
@end
@interface CodePushTelemetryManager : NSObject
+ (NSDictionary *)getBinaryUpdateReport:(NSString *)appVersion;
+ (NSDictionary *)getRetryStatusReport;
+ (NSDictionary *)getRollbackReport:(NSDictionary *)lastFailedPackage;
+ (NSDictionary *)getUpdateReport:(NSDictionary *)currentPackage;
+ (void)recordStatusReported:(NSDictionary *)statusReport;
+ (void)saveStatusReportForRetry:(NSDictionary *)statusReport;
@end
@interface CodePushUpdateUtils : NSObject
+ (void)copyEntriesInFolder:(NSString *)sourceFolder
destFolder:(NSString *)destFolder
error:(NSError **)error;
+ (NSString *)findMainBundleInFolder:(NSString *)folderPath
expectedFileName:(NSString *)expectedFileName
error:(NSError **)error;
+ (NSString *)assetsFolderName;
+ (NSString *)getHashForBinaryContents:(NSURL *)binaryBundleUrl
error:(NSError **)error;
+ (NSString *)manifestFolderPrefix;
+ (NSString *)modifiedDateStringOfFileAtURL:(NSURL *)fileURL;
+ (BOOL)verifyHashForDiffUpdate:(NSString *)finalUpdateFolder
expectedHash:(NSString *)expectedHash
error:(NSError **)error;
@end
void CPLog(NSString *formatString, ...);
typedef NS_ENUM(NSInteger, CodePushInstallMode) {
CodePushInstallModeImmediate,
CodePushInstallModeOnNextRestart,
CodePushInstallModeOnNextResume
};
typedef NS_ENUM(NSInteger, CodePushUpdateState) {
CodePushUpdateStateRunning,
CodePushUpdateStatePending,
CodePushUpdateStateLatest
};