Permalink
Browse files

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
  • Loading branch information...
mkonicek authored and facebook-github-bot-1 committed Jan 8, 2016
1 parent 36dbe86 commit 1dc56a6758c58ae7608bdc130afb7b831194f7ed
Showing with 3 additions and 7 deletions.
  1. +3 −7 Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js
@@ -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);
};
}
}

0 comments on commit 1dc56a6

Please sign in to comment.