Add support for global alert() on Android
Summary: Use the new cross-platform [`Alert`](https://github.com/facebook/react-native/blob/master/Libraries/Utilities/Alert.js) API to implement global `alert()`. public Reviewed By: vjeux Differential Revision: D2773589 fb-gh-sync-id: 4297c5dce6a55391af89d2675f2b9ac4dc715bb6
This commit is contained in:
parent
36dbe86208
commit
1dc56a6758
|
@ -117,15 +117,11 @@ function setUpTimers() {
|
|||
}
|
||||
|
||||
function setUpAlert() {
|
||||
var RCTAlertManager = require('NativeModules').AlertManager;
|
||||
if (!GLOBAL.alert) {
|
||||
GLOBAL.alert = function(text) {
|
||||
var alertOpts = {
|
||||
title: 'Alert',
|
||||
message: '' + text,
|
||||
buttons: [{'cancel': 'OK'}],
|
||||
};
|
||||
RCTAlertManager.alertWithArgs(alertOpts, function () {});
|
||||
// Require Alert on demand. Requiring it too early can lead to issues
|
||||
// with things like Platform not being fully initialized.
|
||||
require('Alert').alert('Alert', '' + text);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue