Skip to content

Commit

Permalink
Add support for global alert() on Android
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Martin Konicek authored and facebook-github-bot-1 committed Jan 8, 2016
1 parent 36dbe86 commit 1dc56a6
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 () {});
}; };
} }
} }
Expand Down

0 comments on commit 1dc56a6

Please sign in to comment.