UrbanApps / Armchair

A simple yet powerful App Review Manager for iOS and OSX in Swift
MIT License
1.2k stars 137 forks source link

userDidSignificantEvent not working #82

Closed Arti3DPlayer closed 6 years ago

Arti3DPlayer commented 8 years ago

In AppDelegate.swift i added:

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        Armchair.appID(APP_ID)
        Armchair.significantEventsUntilPrompt(1)

}

Then in my ViewController:

override func viewDidAppear(_ animated: Bool) {
        Armchair.userDidSignificantEvent(true)
    }

But pop up window never shown. What is wrong ? I'm using swift 3 version

coneybeare commented 8 years ago

Please place a debugger call and step through to determine at which point the plugin has determined your app is not ready for displaying a rating prompt.

3adel commented 8 years ago

Any update on this? I am having the same issue with swift3 branch

coneybeare commented 8 years ago

If you step through the logic, you will be able to see at which point the plugin determined the rating criteria have not been met.

jeffvstudio commented 6 years ago

I had the same issue and found why is it:

Reason is because even you're not using some of the flags, they're set and have default values already, which means you have to set it as your convenience in order to make it work properly. I set my own values for these flags and got it working.

Look, this function is the one in the library which decides whether rate conditions have been met or not, so you can see for instance that if daysUntilPrompt (default value of 30 btw) is not met yet bcz you just started testing your app today, it will return and you won't see the prompt, and so on with the remaining flags.

Hope it helps!

fileprivate func ratingConditionsHaveBeenMet() -> Bool {
        if debugEnabled {
            return true
        }

        if appID.isEmpty {
            return false
        }

        // check if the app has been used long enough
        let timeIntervalOfFirstLaunch = userDefaultsObject?.doubleForKey(keyForArmchairKeyType(ArmchairKey.FirstUseDate))
        if let timeInterval = timeIntervalOfFirstLaunch {
            let dateOfFirstLaunch = Date(timeIntervalSince1970: timeInterval)
            let timeSinceFirstLaunch = Date().timeIntervalSince(dateOfFirstLaunch)
            let timeUntilRate: TimeInterval = 60 * 60 * 24 * Double(daysUntilPrompt)
            if timeSinceFirstLaunch < timeUntilRate {
                return false
            }
        } else {
            return false
        }

        // check if the app has been used enough times
        let useCount = userDefaultsObject?.integerForKey(keyForArmchairKeyType(ArmchairKey.UseCount))
        if let count = useCount {
            if UInt(count) <= usesUntilPrompt {
                return false
            }
        } else {
            return false
        }

        // check if the user has done enough significant events
        let significantEventCount = userDefaultsObject?.integerForKey(keyForArmchairKeyType(ArmchairKey.SignificantEventCount))
        if let count = significantEventCount {
            if UInt(count) < significantEventsUntilPrompt {
                return false
            }
        } else {
            return false
        }

        // Check if the user previously has declined to rate this version of the app
        if userHasDeclinedToRate() {
            return false
        }

        // Check if the user has already rated the app?
        if userHasRatedCurrentVersion() {
            return false
        }

        // If the user wanted to be reminded later, has enough time passed?
        let timeIntervalOfReminder = userDefaultsObject?.doubleForKey(keyForArmchairKeyType(ArmchairKey.ReminderRequestDate))
        if let timeInterval = timeIntervalOfReminder {
            let reminderRequestDate = Date(timeIntervalSince1970: timeInterval)
            let timeSinceReminderRequest = Date().timeIntervalSince(reminderRequestDate)
            let timeUntilReminder: TimeInterval = 60 * 60 * 24 * Double(daysBeforeReminding)
            if timeSinceReminderRequest < timeUntilReminder {
                return false
            }
        } else {
            return false
        }

        // if we have a global set to not show if the end-user has already rated once, and the developer has not opted out of displaying on minor updates
        let ratedAnyVersion = userDefaultsObject?.boolForKey(keyForArmchairKeyType(ArmchairKey.RatedAnyVersion))
        if let ratedAlready = ratedAnyVersion {
            if (!shouldPromptIfRated && ratedAlready) {
                return false
            }
        }

        return true
    }