ArtSabintsev / Siren

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

Alert not displaying #331

Closed rigaldamez closed 4 years ago

rigaldamez commented 4 years ago

I have just installed Siren version 5.4.0 using pod 'Siren' in my pod file.

I have an app version 1.5 which was last published in the appStore approx 2 months ago.

The version details in my xcode project file are:

Version: 0.0.5 Build: 1

(AppStore published version: 1.5)

When testing I change to Version 0.0.1 then build/run the app and no alert pops up.

I am testing using the provided sample in my AppDelegate.swift file

import Siren

var window: UIWindow?

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

window?.makeKeyAndVisible()
defaultExampleUsingCompletionHandler()

//...other code eg; Firebase, Facebook initialisation code, present login VC if currentUser == nil

}
private extension AppDelegate {

    // The simplest implementation of Siren.
    // All default rules are implemented and the
    // results of the completion handler are ignored.
    func defaultExample() {
        Siren.shared.wail()
    }

    // The simplest implementation of Siren.
    // All default rules are implemented and the
    // results of the completion handler are returned or an error is returned.
    func defaultExampleUsingCompletionHandler() {

        print("defaultExampleUsingCompletionHandler")

        Siren.shared.wail { results in
            switch results {
            case .success(let updateResults):
                print("AlertAction ", updateResults.alertAction)
                print("Localization ", updateResults.localization)
                print("Model ", updateResults.model)
                print("UpdateType ", updateResults.updateType)
            case .failure(let error):
                print(error.localizedDescription)
            }
        }
    }

}//end extension
ArtSabintsev commented 4 years ago

Hi, could you provide me with your bundle identifier so I can test this in the sample app? Also, feel free to edit the example xcode project that's in this repo and see if works for you there as that's what I plan to do with your bundle ID once you provide it.

Thanks!

Edit: here's how you do it - https://github.com/ArtSabintsev/Siren#testing-siren-locally

rigaldamez commented 4 years ago

I downloaded the sample project, tried to build and run but got tens of errors :/

ArtSabintsev commented 4 years ago

What version of Xcode are you using?

rigaldamez commented 4 years ago

I'm using the following;

Xcode: 11.2.1 ios Deployment Target: 13.0 Swift: 5.0

ArtSabintsev commented 4 years ago

Ah, that may be why. Please upgrade to the latest version of Xcode, 11.4.1 and follow up here if it fixes the issue or not.

Thanks!

rigaldamez commented 4 years ago

I just updated to Xcode 14.4.1 and it's still not displaying the Alert.

I see defaultExampleUsingCompletionHandler debug line being printed out to the console so the code reached the function but not alert

ArtSabintsev commented 4 years ago

ok, per the log:

[Siren Error] Error retrieving App Store data as the JSON results were empty. Is your app available in the US? If not, change the `countryCode` variable to fix this error.

Is your app available in the US App Store? If not, please do the following:

let siren = Siren.shared
siren.apiManager = APIManager(countryCode: "RU")

See this example for more information: https://github.com/ArtSabintsev/Siren/blob/ca3559cd93f7c496d10e21ca2b24d1611e7ff75c/Example/Example/AppDelegate.swift#L224-L242

Does this help?

rigaldamez commented 4 years ago

Yep! this has worked.

Changing it to the correct countryCode worked. thanks for your assistance and for providing such a useful library :)

rigaldamez commented 4 years ago

just a quick follow-up, I have changed the version to 1.5 in Xcode , made it globalRules: .annoying

Should the alert still pop-up even though the version in my project matches the version published in the AppStore (I expect not to show alert since the version matches)?

ArtSabintsev commented 4 years ago

hey - happy to help! Glad it worked!

It should not still pop up if the versions are matching exactly; meaning 1.5 is in the app store. Is the version in the app store 1.5 or 1.5.0? If it's 1.5.0, then it may still pop up. Maybe I have a unit test for it - I don't recall.

ArtSabintsev commented 4 years ago

I looked at the unit tests, and I test that case. It shouldn't happen. What country code are you using, so I ca replicate this on my end for your app.

rigaldamez commented 4 years ago

AppStore is version 1.5

Xcode is Build 1, Version 0.0.5

Country code: AU

ArtSabintsev commented 4 years ago

I don't see this issue using the bundle ID that's in the example app (which references the App Store Connect app) and the latest version at this time (1.4.2).

What's your bundle ID again?

rigaldamez commented 4 years ago

My bundle is: com.rigaldamez.vipeeps

current AppStore version 1.5

I have tried the following...

Testing with Xcode is Build 1, Version 0.0.5 and a lower Version 0.0.4 I get the same results.

When I set to .persistent the alert does not show When I set to .annoying the alert shows every time app becomes active even though the version matches the one in the AppStore

ArtSabintsev commented 4 years ago

I did the following just now in Xcode 11.4.1 and Siren v5.4.0 using Swift 5.0 (probably 5.2, since you cant set that directly to my knowledge).

bundleID: com.rigaldamez.vipeeps
version: 1.5
build: 1 (this doesn't matter)
countryCode: "AU"
alertType: .annoying

With 1.4, I saw the alert. With 1.5 I did not. I did this with many different numbers and was not able to reproduce this issue.

I can't reproduce this on my end with the sample project. Everything seems to work as expected on my end.

ArtSabintsev commented 4 years ago

Closing this issue due to lack of follow up and as I cannot reproduce this issue on my end.