This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ @implementation CodePush {
26
26
27
27
#pragma mark - Private constants
28
28
29
+ // These constants represent emitted events
30
+ static NSString *const DownloadProgressEvent = @" CodePushDownloadProgress" ;
31
+
29
32
// These constants represent valid deployment statuses
30
33
static NSString *const DeploymentFailed = @" DeploymentFailed" ;
31
34
static NSString *const DeploymentSucceeded = @" DeploymentSucceeded" ;
@@ -296,7 +299,7 @@ - (void)dealloc
296
299
297
300
- (void )dispatchDownloadProgressEvent {
298
301
// Notify the script-side about the progress
299
- [self sendEventWithName: @" CodePushDownloadProgress "
302
+ [self sendEventWithName: DownloadProgressEvent
300
303
body: @{
301
304
@" totalBytes" : [NSNumber
302
305
numberWithLongLong: _latestExpectedContentLength],
@@ -537,6 +540,10 @@ - (void)savePendingUpdate:(NSString *)packageHash
537
540
[preferences synchronize ];
538
541
}
539
542
543
+ - (NSArray <NSString *> *)supportedEvents {
544
+ return @[DownloadProgressEvent];
545
+ }
546
+
540
547
#pragma mark - Application lifecycle event handlers
541
548
542
549
// These two handlers will only be registered when there is
Original file line number Diff line number Diff line change 1
1
import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk" ;
2
- import { DeviceEventEmitter } from "react-native" ;
2
+ import { NativeEventEmitter } from "react-native" ;
3
3
import RestartManager from "./RestartManager" ;
4
4
5
5
// This function is used to augment remote and local
@@ -15,8 +15,9 @@ module.exports = (NativeCodePush) => {
15
15
16
16
let downloadProgressSubscription ;
17
17
if ( downloadProgressCallback ) {
18
+ const codePushEventEmitter = new NativeEventEmitter ( NativeCodePush ) ;
18
19
// Use event subscription to obtain download progress.
19
- downloadProgressSubscription = DeviceEventEmitter . addListener (
20
+ downloadProgressSubscription = codePushEventEmitter . addListener (
20
21
"CodePushDownloadProgress" ,
21
22
downloadProgressCallback
22
23
) ;
You can’t perform that action at this time.
0 commit comments