Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ios/CodePush/CodePush.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ @implementation CodePush {

#pragma mark - Private constants

// These constants represent emitted events
static NSString *const DownloadProgressEvent = @"CodePushDownloadProgress";

// These constants represent valid deployment statuses
static NSString *const DeploymentFailed = @"DeploymentFailed";
static NSString *const DeploymentSucceeded = @"DeploymentSucceeded";
Expand Down Expand Up @@ -296,7 +299,7 @@ - (void)dealloc

- (void)dispatchDownloadProgressEvent {
// Notify the script-side about the progress
[self sendEventWithName:@"CodePushDownloadProgress"
[self sendEventWithName:DownloadProgressEvent
body:@{
@"totalBytes" : [NSNumber
numberWithLongLong:_latestExpectedContentLength],
Expand Down Expand Up @@ -537,6 +540,10 @@ - (void)savePendingUpdate:(NSString *)packageHash
[preferences synchronize];
}

- (NSArray<NSString *> *)supportedEvents {
return @[DownloadProgressEvent];
}

#pragma mark - Application lifecycle event handlers

// These two handlers will only be registered when there is
Expand Down
5 changes: 3 additions & 2 deletions package-mixins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
import { DeviceEventEmitter } from "react-native";
import { NativeEventEmitter } from "react-native";
import RestartManager from "./RestartManager";

// This function is used to augment remote and local
Expand All @@ -15,8 +15,9 @@ module.exports = (NativeCodePush) => {

let downloadProgressSubscription;
if (downloadProgressCallback) {
const codePushEventEmitter = new NativeEventEmitter(NativeCodePush);
// Use event subscription to obtain download progress.
downloadProgressSubscription = DeviceEventEmitter.addListener(
downloadProgressSubscription = codePushEventEmitter.addListener(
"CodePushDownloadProgress",
downloadProgressCallback
);
Expand Down