forked from microsoft/react-native-code-push
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlertAdapter.js
More file actions
24 lines (19 loc) · 703 Bytes
/
AlertAdapter.js
File metadata and controls
24 lines (19 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import React, { Platform } from "react-native";
let { Alert } = React;
if (Platform.OS === "android") {
const { NativeModules: { CodePushDialog } } = React;
Alert = {
alert(title, message, buttons) {
if (buttons.length > 2) {
throw "Can only show 2 buttons for Android dialog.";
}
const button1Text = buttons[0] ? buttons[0].text : null,
button2Text = buttons[1] ? buttons[1].text : null;
CodePushDialog.showDialog(
title, message, button1Text, button2Text,
(buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); },
(error) => { throw error; });
}
};
}
module.exports = { Alert };