ReviewPrompter is an open-source library for iOS applications written in Swift that helps you intelligently prompt users for app reviews. It tracks the occurrence of specific events within your app and requests a review prompt when the specified conditions are met. ReviewPrompter ensures that users are not prompted too frequently by implementing a minimum time interval between each prompt.
ReviewPrompter
is a subclass of EventTracker
and so depends on the EventTracker library.
- Tracks occurrences of named events in your app
- Requests review prompts when the number of events matches the specified condition
- Ensures a minimum time interval between each prompt
- Allows for manual triggering of review prompts
- Supports event count resetting
- Provides an option to enable or disable logging
The library is basically fully tested with 98.5% code coverage
To add ReviewPrompter to your project using Swift Package Manager, add the following dependency in your Package.swift file:
dependencies: [
.package(url: "https://github.com/ChristianFox/ReviewPrompter.git", from: "1.0.0")
]
Don't forget to add ReviewPrompter to your target dependencies:
targets: [
.target(
name: "YourTarget",
dependencies: ["ReviewPrompter"]),
]
Initialise an instance
let reviewPrompter = ReviewPrompter(minimumPromptInterval: 60 * 60 * 24 * 7) // 1 week
Increase the event count and request a review prompt if the condition is met. Callback is used to inform the caller if a review prompt has been requested.
do {
try reviewPrompter.increaseEventCountWithReviewPrompt(forIdentifier: "event1") { didRequestReview in
print("Review prompt requested: \(didRequestReview)")
}
} catch {
print("Error: \(error)")
}
Manually triggr a review prompt
let didRequest = reviewPrompter.requestReviewPrompt()
print("Review prompt requested: \(didRequest)")
If needed, you can delete the history of review prompt dates with the deleteHistoryOfReviewPromptDates() method:
reviewPrompter.deleteHistoryOfReviewPromptDates()
Begin tracking an event
reviewPrompter.trackEvent(forIdentifier: "event1", withCondition: 3)
Stop tracking an event
reviewPrompter.stopTrackingEvent(forIdentifier: "event1")
Change the condition for an event
do {
try reviewPrompter.changeCondition(5, forIdentifier: "event1")
} catch {
print("Error updating event condition: \(error)")
}
Increase the event count
do {
try reviewPrompter.increaseEventCount(forIdentifier: "event1")
} catch {
print("Error increasing event count: \(error)")
}
Reset the event count
do {
try reviewPrompter.resetEventCount(forIdentifier: "event1")
} catch {
print("Error resetting event count: \(error)")
}
Check if an event's condition has been met
if reviewPrompter.hasEventMetCondition(forIdentifier: "event1") {
print("Event met condition!")
}
Check an event is being tracked
if reviewPrompter.isTrackingEvent(forIdentifier: "event1") {
print("Event is being tracked!")
}
Check the number of times an event has occured
let eventCount = reviewPrompter.eventCount(forIdentifier: "event1")
print("Event count: \(eventCount)")
Check the current condition of an event
let eventCondition = reviewPrompter.condition(forIdentifier: "event1")
print("Event condition: \(eventCondition)")
Please open an issue for support.
Pull requests are welcome. I welcome developers of all skill levels to help improve the library, fix bugs, or add new features.
For major changes, please open an issue first to discuss what you would like to change.
Before submitting a pull request, please ensure that your code adheres to the existing code style and conventions, and that all tests pass. Additionally, if you're adding new functionality, please make sure to include unit tests to verify the behavior.
If you have any questions or need assistance, feel free to open an issue, and I'll do my best to help you out.
ReviewPrompter is released under the MIT Licence. See the LICENSE file for more information.