Skip to content

Commit 6dc7e65

Browse files
committed
Remove android custom Alert
1 parent feffe63 commit 6dc7e65

5 files changed

Lines changed: 10 additions & 168 deletions

File tree

android/app/src/main/java/com/appzung/codepush/react/CodePush.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,9 @@ static ReactInstanceManager getReactInstanceManager() {
427427
@Override
428428
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
429429
CodePushNativeModule codePushModule = new CodePushNativeModule(reactApplicationContext, this, mUpdateManager, mTelemetryManager, mSettingsManager);
430-
CodePushDialog dialogModule = new CodePushDialog(reactApplicationContext);
431430

432431
List<NativeModule> nativeModules = new ArrayList<>();
433432
nativeModules.add(codePushModule);
434-
nativeModules.add(dialogModule);
435433
return nativeModules;
436434
}
437435

android/app/src/main/java/com/appzung/codepush/react/CodePushDialog.java

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/internals/AlertAdapter.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/reactNative.d.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,25 @@ declare module "react-native" {
55
export const Platform: PlatformStatic;
66

77
export interface NativeEventSubscription {
8-
/**
9-
* Call this method to un-subscribe from a native-event
10-
*/
118
remove(): void;
129
}
1310

1411
type AppStateStatus = string;
15-
1612
export interface AppStateStatic {
1713
currentState: AppStateStatus;
18-
isAvailable: boolean;
19-
20-
/**
21-
* Add a handler to AppState changes by listening to the change event
22-
* type and providing the handler
23-
*/
2414
addEventListener(
2515
type: AppStateEvent,
2616
listener: (state: AppStateStatus) => void,
2717
): NativeEventSubscription;
2818
}
2919
export const AppState: AppStateStatic;
3020

31-
/**
32-
* Interface for NativeModules which allows to augment NativeModules with type informations.
33-
* See react-native-sensor-manager for example.
34-
*/
35-
interface NativeModulesStatic {
36-
[name: string]: any;
21+
export interface AlertButton {
22+
text?: string;
23+
onPress?: () => void;
3724
}
38-
39-
/**
40-
* Native Modules written in ObjectiveC/Swift/Java exposed via the RCTBridge
41-
* Define lazy getters for each module. These will return the module if already loaded, or load it if not.
42-
* See https://reactnative.dev/docs/native-modules-ios
43-
* @example
44-
* const MyModule = NativeModules.ModuleName
45-
*/
46-
export const NativeModules: NativeModulesStatic;
47-
48-
export const Alert: any;
25+
interface AlertStatic {
26+
alert(title: string, message?: string, buttons?: AlertButton[]): void;
27+
}
28+
export const Alert: AlertStatic;
4929
}

src/sync.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import type {
66
UpdateDialog
77
} from "./types";
88
import { log } from "./internals/utils/log";
9-
import {Alert, type Button} from "./internals/AlertAdapter";
109
import { SyncStatus } from "./enums/SyncStatus.enum";
1110
import { shouldUpdateBeIgnored } from "./internals/shouldUpdateBeIgnored";
1211
import { checkForUpdate } from "./checkForUpdates";
1312
import { InstallMode } from "./enums/InstallMode.enum";
1413
import { getCurrentPackage } from "./internals/getCurrentPackage";
1514
import { notifyAppReady } from "./notifyAppReady";
15+
import { Alert, type AlertButton, Platform } from "react-native";
1616

1717
/**
1818
* Represents the default settings that will be used by the sync method if
@@ -137,7 +137,7 @@ async function syncInternal(options?: SyncOptions, syncStatusChangeCallback?: Sy
137137
let message: string | undefined;
138138
let installButtonText: string | undefined;
139139

140-
const dialogButtons: Button[] = [];
140+
const dialogButtons: AlertButton[] = [];
141141

142142
if (remotePackage.isMandatory) {
143143
message = updateDialogConfig.mandatoryUpdateMessage;
@@ -173,7 +173,7 @@ async function syncInternal(options?: SyncOptions, syncStatusChangeCallback?: Sy
173173
}
174174

175175
syncStatusChangeCallback(SyncStatus.AWAITING_USER_ACTION);
176-
Alert.alert(updateDialogConfig.title || "", message || "", dialogButtons);
176+
Alert.alert(updateDialogConfig.title || "", message || "", Platform.OS === "android" ? [...dialogButtons.reverse()] : dialogButtons);
177177
});
178178
} else {
179179
return await doDownloadAndInstall();

0 commit comments

Comments
 (0)