question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Alerts stacked on iOS instead of being replaced

See original GitHub issue

Is this a bug report?

Yes

Have you read the Bugs section of the Contributing to React Native Guide?

yes

Environment

react-native-cli: 1.0.0 react-native: 0.43.4 (simulator screenshots) and 0.45.1 (Expo demo) node: v7.7.4 npm: 4.1.2

Then, specify:

  1. Target Platform: iOS
  2. Development Operating System macOS Sierra
  3. Build tools Xcode (8.3)

Steps to Reproduce

Displaying successive Alerts on iOS leads to an overlay (multiple Alerts displayed, you need to click them one by one to get back to the app)

Alert.alert('title', 'lorem', [
  { text: 'cancel', onPress: () => true },
  { text: 'read', onPress: () => this.doWhatever() },
]);

Expected Behavior

On Android, if an Alert is already displayed when calling Alert.alert the new Alert replace the previous one. It should be the same on iOS since there is no way to delete / cancel alert without pressing the buttons on it.

Actual Behavior

Alerts are stacked on iOS instead of being replaced when a new one is created, both on simulator and on device, even build with a release scheme.

Reproducible Demo

I’ve setup an Expo project here: run it on iOS to reproduce the bug.

https://github.com/weassur/RNAlertBug

and a snack:

https://snack.expo.io/rynGz03N-

there are no dependencies other than to the Alert API

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Ehespcommented, Jul 10, 2017

I always thought this was expected iOS behaviour. Agreed it’s annoying as you can’t have the same code base to handle alerts.

0reactions
alexandrzavaliicommented, Mar 3, 2018

Is there a way to close old Alert before showing the new one ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stacked notifications on lock screen. - Apple Community
Open the Settings app and tap Notifications. Select the app you want to enable or disable group notifications for. Scroll down and tap ......
Read more >
Stop multiple alerts for incoming message etc. on iPhone
Settings → Notifications → Messages → Repeat Alerts and set it to Never. For what it's worth, the default setting of repeat once...
Read more >
Multiple alerts on top of each other in swift - Stack Overflow
There is my code, it shows alert if item is posted more than day ago. Two ways i have tried to do this...
Read more >
How to Control Annoying Notifications on Your iPhone
To do this, go to Settings > Notifications > [App Name] > Notification Grouping. The default is the Automatic option. To force iOS...
Read more >
How to show multiple alerts in a single view - Hacking with Swift
To solve this, you need to make sure you attach no more than one alert() modifier to each view.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found