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
1 changed files with 3 additions and 7 deletions

View File

@ -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);
};
}
}