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
Latest commit
24 lines (19 loc) · 703 Bytes
/
Copy pathAlertAdapter.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
importReact,{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.";
}
constbutton1Text=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)=>{throwerror;});
}
};
}
module.exports={ Alert };