How to cancel AlertIOS programatically
Description
I have a component with Barcode scanner. After the barcode scanner returns a value, the AlertIOS with a prompt shows up, with Cancel and Save buttons. Now one option is to click Save button for sending the value to the server. For the other option, the client wishes to send data with volume down button or cancel with volume up button.
Problem
Now I already have set up confirmation with volume down button, but I would also like to close the Alert popup when pressing any of the buttons.
My code
For alert:
showAlert(value) {
this.alert = AlertIOS.prompt(
`Gescannter Wert: ${value}`,
'Menge eingeben (Standartwert ist 1)',
[{
text: 'Cancel',
onPress: () => this.scanning = true,
style: 'cancel',
},
{
text: 'Save',
onPress: (input) => this.pushCodeData(value, input)
}],
'plain-text',
'1',
'number-pad',
);
}
for volume change detection:
this.volumeListener = SystemSetting.addVolumeListener((data) => {
let volume = data.value.toFixed(1);
console.log(volume, this.VOLUME);
SystemSetting.setVolume(this.VOLUME);
if (volume < this.VOLUME && this.scanning === false) {
console.log("confirm")
this.pushCodeData(this.state.scannedValue, 1)
} else if (volume > this.VOLUME && this.scanning === false){
console.log("cancel")
this.scanning = true
}
});
The function that sends the data is this.pushCodeData(params...)
Is it even possible to programatically close the alert prompt? So far I couldn't find any answers to this.
javascript react-native
add a comment |
Description
I have a component with Barcode scanner. After the barcode scanner returns a value, the AlertIOS with a prompt shows up, with Cancel and Save buttons. Now one option is to click Save button for sending the value to the server. For the other option, the client wishes to send data with volume down button or cancel with volume up button.
Problem
Now I already have set up confirmation with volume down button, but I would also like to close the Alert popup when pressing any of the buttons.
My code
For alert:
showAlert(value) {
this.alert = AlertIOS.prompt(
`Gescannter Wert: ${value}`,
'Menge eingeben (Standartwert ist 1)',
[{
text: 'Cancel',
onPress: () => this.scanning = true,
style: 'cancel',
},
{
text: 'Save',
onPress: (input) => this.pushCodeData(value, input)
}],
'plain-text',
'1',
'number-pad',
);
}
for volume change detection:
this.volumeListener = SystemSetting.addVolumeListener((data) => {
let volume = data.value.toFixed(1);
console.log(volume, this.VOLUME);
SystemSetting.setVolume(this.VOLUME);
if (volume < this.VOLUME && this.scanning === false) {
console.log("confirm")
this.pushCodeData(this.state.scannedValue, 1)
} else if (volume > this.VOLUME && this.scanning === false){
console.log("cancel")
this.scanning = true
}
});
The function that sends the data is this.pushCodeData(params...)
Is it even possible to programatically close the alert prompt? So far I couldn't find any answers to this.
javascript react-native
add a comment |
Description
I have a component with Barcode scanner. After the barcode scanner returns a value, the AlertIOS with a prompt shows up, with Cancel and Save buttons. Now one option is to click Save button for sending the value to the server. For the other option, the client wishes to send data with volume down button or cancel with volume up button.
Problem
Now I already have set up confirmation with volume down button, but I would also like to close the Alert popup when pressing any of the buttons.
My code
For alert:
showAlert(value) {
this.alert = AlertIOS.prompt(
`Gescannter Wert: ${value}`,
'Menge eingeben (Standartwert ist 1)',
[{
text: 'Cancel',
onPress: () => this.scanning = true,
style: 'cancel',
},
{
text: 'Save',
onPress: (input) => this.pushCodeData(value, input)
}],
'plain-text',
'1',
'number-pad',
);
}
for volume change detection:
this.volumeListener = SystemSetting.addVolumeListener((data) => {
let volume = data.value.toFixed(1);
console.log(volume, this.VOLUME);
SystemSetting.setVolume(this.VOLUME);
if (volume < this.VOLUME && this.scanning === false) {
console.log("confirm")
this.pushCodeData(this.state.scannedValue, 1)
} else if (volume > this.VOLUME && this.scanning === false){
console.log("cancel")
this.scanning = true
}
});
The function that sends the data is this.pushCodeData(params...)
Is it even possible to programatically close the alert prompt? So far I couldn't find any answers to this.
javascript react-native
Description
I have a component with Barcode scanner. After the barcode scanner returns a value, the AlertIOS with a prompt shows up, with Cancel and Save buttons. Now one option is to click Save button for sending the value to the server. For the other option, the client wishes to send data with volume down button or cancel with volume up button.
Problem
Now I already have set up confirmation with volume down button, but I would also like to close the Alert popup when pressing any of the buttons.
My code
For alert:
showAlert(value) {
this.alert = AlertIOS.prompt(
`Gescannter Wert: ${value}`,
'Menge eingeben (Standartwert ist 1)',
[{
text: 'Cancel',
onPress: () => this.scanning = true,
style: 'cancel',
},
{
text: 'Save',
onPress: (input) => this.pushCodeData(value, input)
}],
'plain-text',
'1',
'number-pad',
);
}
for volume change detection:
this.volumeListener = SystemSetting.addVolumeListener((data) => {
let volume = data.value.toFixed(1);
console.log(volume, this.VOLUME);
SystemSetting.setVolume(this.VOLUME);
if (volume < this.VOLUME && this.scanning === false) {
console.log("confirm")
this.pushCodeData(this.state.scannedValue, 1)
} else if (volume > this.VOLUME && this.scanning === false){
console.log("cancel")
this.scanning = true
}
});
The function that sends the data is this.pushCodeData(params...)
Is it even possible to programatically close the alert prompt? So far I couldn't find any answers to this.
javascript react-native
javascript react-native
asked Nov 12 at 9:59
Razmooo
121119
121119
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It's not possible to close an alert programmatically yet. https://github.com/facebook/react-native/issues/4928
You may give it a try.
How can I remove Alert prompts programmatically?
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259728%2fhow-to-cancel-alertios-programatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's not possible to close an alert programmatically yet. https://github.com/facebook/react-native/issues/4928
You may give it a try.
How can I remove Alert prompts programmatically?
add a comment |
It's not possible to close an alert programmatically yet. https://github.com/facebook/react-native/issues/4928
You may give it a try.
How can I remove Alert prompts programmatically?
add a comment |
It's not possible to close an alert programmatically yet. https://github.com/facebook/react-native/issues/4928
You may give it a try.
How can I remove Alert prompts programmatically?
It's not possible to close an alert programmatically yet. https://github.com/facebook/react-native/issues/4928
You may give it a try.
How can I remove Alert prompts programmatically?
answered Nov 12 at 10:47
Aaditya Paliwal
568
568
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259728%2fhow-to-cancel-alertios-programatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown