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:
Martin Konicek
2016-01-08 10:11:46 -08:00
committed by facebook-github-bot-1
parent 36dbe86208
commit 1dc56a6758

View File

@@ -117,15 +117,11 @@ function setUpTimers() {
} }
function setUpAlert() { function setUpAlert() {
var RCTAlertManager = require('NativeModules').AlertManager;
if (!GLOBAL.alert) { if (!GLOBAL.alert) {
GLOBAL.alert = function(text) { GLOBAL.alert = function(text) {
var alertOpts = { // Require Alert on demand. Requiring it too early can lead to issues
title: 'Alert', // with things like Platform not being fully initialized.
message: '' + text, require('Alert').alert('Alert', '' + text);
buttons: [{'cancel': 'OK'}],
};
RCTAlertManager.alertWithArgs(alertOpts, function () {});
}; };
} }
} }