ArtSabintsev / Siren

Notify users when a new version of your app is available and prompt them to upgrade.
http://sabintsev.com/
MIT License
4.26k stars 407 forks source link

Multiple alerts stacked on eachother when Siren.sharedInstance.alertType changed #91

Closed royherma closed 7 years ago

royherma commented 8 years ago

I've got logic that sets Siren.sharedInstance.alertType several times, and its causing Siren to pop-up multiple alerts on top of each other. Any way to only allow 1 alert at a time?

Thanks!

royherma commented 8 years ago

Ended up implementing a fix myself by adding a boolean isDisplaying flag.

ArtSabintsev commented 8 years ago

Sounds good.

mamouneyya commented 7 years ago

This is very annoying. I think it should be solved in the library itself.

@royherma How would you detect if it's currently displayed? Any reliable way other than manually tracking this using sirenDidShowUpdateDialog(alertType:), sirenUserDidLaunchAppStore(), sirenUserDidSkipVersion() and sirenUserDidCancel?

getaaron commented 7 years ago

Could you share some context about why you're setting the alert type multiple times? Just want to better understand the problem you're solving.

ArtSabintsev commented 7 years ago

@mamouneyya Are you asking to figure out if a UIAlertController is being displayed?

More context would be ideal. The more detail, the easier it will be for us to answer this question.

mamouneyya commented 7 years ago

Well, I'm a little bit confused now. I followed the instructions by calling checkVersion method at the following AppDelegate's methods:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    //...

    Siren.sharedInstance.checkVersion(checkType: .immediately)

    return true
}
func applicationDidBecomeActive(_ application: UIApplication) {
    Siren.sharedInstance.checkVersion(checkType: .daily)
}
func applicationWillEnterForeground(_ application: UIApplication) {
    if Defaults[.AppUpdateAlertType] == .force {
        Siren.sharedInstance.checkVersion(checkType: .immediately)
    }
}

However, the library seems to be presenting an alert with each call of those even though a one or more are already presented (e.g. I'm getting three alerts when in force mode)...

ArtSabintsev commented 7 years ago

First things first,

What version of your app is currently in the store, if any? What version is currently set in the info.plist?

mamouneyya commented 7 years ago

It's not published to the store yet, so I am trying with the bundle identifier 'com.apple.itunesconnect.mobile' and version 1.0, as suggested in the README file. The problem is not with the fact that the library does show an alert (it should do so).. the problem is that it displays another alert though a one is already displayed.. ending up with three stacked alerts.

ArtSabintsev commented 7 years ago

ok, got it - thanks for that detailed explanation. This is most likely a bug in Siren and I will take a look at it now. I don't use .force often, meaning I also don't make use of Siren in applicationWillEnterForeground, which is probably why the issue is popping up.

Thanks for the info. I'll look at it now.

ArtSabintsev commented 7 years ago

@royherma @mamouneyya @getaaron

The fix was merged and is available in Siren v1.1.3 via all dependency managers.

mamouneyya commented 7 years ago

I can confirm that the update fixed the issue for me. Thank you!