Latest0.1.0
Homepagehttps://github.com/smartnsoft/StarsKit
LicenseMIT
Platformsios 9.0
DependenciesCosmos, Extra/UIKit, Jelly
FrameworksUIKit
Authors

CI Status
Version
License
Platform

StarsKit

Look at this beautiful MouSTARche!

StarsKit is a Swift library to simplify, customize and configure your iOS app rating workflow.

It can be based on a remote, local or static configuration data with optionnals properties.

StarsKitStarsKitStarsKit

Requirements

  • iOS 9.0+
  • Swift 4+
  • Xcode 9.2+

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

StarsKit is available through CocoaPods. To install
it, add the following line to your Podfile:

pod 'StarsKit'

Third-party dependencies

Today we have third-parties dependencies, but the purpose is to avoid them the most.

We also want to have a quickly available library and significant customization, we use 3 dependencies:

  • Extra/UIKit: our library to simplify UIKit operation code
  • Jelly: a simple UI component to simplify the rating transition display
  • Cosmos: a powerful and flexible stars slider UI component

Description

Behavior

The main feature of the library is to use static or dynamic (remote) configuration to show native or custom app rating screen.

If the user chooses a negative rate, he will be redirected to the feedback screen.
If the user chooses a positive rate, he will be redirected to the Store review screen.

You and only you choose what to do when the user chooses to give a feedback, like:

  • send an e-mail
  • launch your own feedback screen

It’s the same when the user chooses to rate the app:

  • redirect the user to the AppStore review page
  • call a custom analytics

Native StoreKit screen

You can also display the native StoreKit screen instead of custom screens (iOS 10.3+ only):

StarsKit

Features list

  • [X] Use localizable or configuration strings
  • [X] Default localizable strings :
    • [X] EN
    • [X] FR
  • [X] Overridable localizable strings
  • [X] Static configuration strings
  • [X] Cocoapods integration
  • [X] Default & configurable step transitions
  • [X] Default display algorithm behavior
  • [X] Customizable display algorithm behavior
  • [X] Customizable stars style
  • [X] Customizable fonts, text & tint colors
  • [X] Rating & screen actions callbacks
  • [X] Configurable with dictionary/data or remote URL: everything you want!
  • [X] Native iOS 10.3+ StoreKit integration
  • [X] Overridable layouts
  • [X] Lifecycle display events ([will/did]appear/disappear)
  • [ ] Additional condition checking on the default check
  • [ ] Carthage integration
  • [ ] Configurable key for parsing
  • [ ] Firebase extension to bind Remote Config to StarsKit data

Configurable metrics for display

You can specify metrics to trigger the default display behavior or use your own one.

  • [X] Disable/enable the component
  • [X] Increment sessions counter
  • [X] Increment crashes counter
  • [X] Static configuration strings
  • [X] Days without crashes
  • [X] Days before asking again
  • [X] Number of reminding
  • [X] Maximum of days between session count
  • [X] email properties: mail address, mail subject, mail header body
  • [X] Step 1: Rate screen properties
  • [X] Step 2: Feedback screen properties
  • [X] Step 3: Store review screen properties

Usage

Display the rating

// Call this, the algorithm will do the rest:
StarsKit.shared.displayRateIfNeeded()

// You can also force the display:
StarsKit.shared.displayRateIfNeeded(forced: true)

Update the configuration properties

See also: StarsKitConfigProperties enum keys.
You have to conform the data dictionary to the expected keys.

StarsKit offers you the possibility of using any configuration source: local JSON file, static dictionnary, remote file (remote JSON or Firebase remote configuration file).

JSON StarsKit configuration example:

{
    "disabled": false,
    "displaySessionCount": 3,
    "mainTitle": "Your opinion interests us :)",
    "mainText": "Do you like the app StarsKit?",
    "mainActionButton": "Submit",
    "positiveStarsLimit": 4,
    "dislikeMainTitle": "Your opinion interests us",
    "dislikeMainText": "Help us to improve the app StarsKit",
    "dislikeActionButton": "Make a suggestion",
    "dislikeExitButton": "Later",
    "likeMainTitle": "You like our app! Thanks!",
    "likeMainText": "Let us know on the AppStore in a minute!",
    "likeActionButton": "Let's go!",
    "likeExitButton": "Later 😥",
    "maxNumberOfReminder": 3,
    "maxDaysBetweenSession": 3,
    "emailSupport": "[email protected]",
    "emailObject": "Application StarsKit",
    "daysWithoutCrash": 15,
    "daysBeforeAskingAgain": 3,
    "emailHeaderContent": "Why do you not like the app?"
}

To update the configuration, give the dictionnary data :

let data = try Data(contentsOf: URL(fileURLWithPath: path))
let localJSONConfiguration = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! [String: Any?]
StarsKit.shared.updateConfig(from: localJSONConfiguration)

StarsKit instance & configuration

Today StarsKit manages a default singleton instance.

You can set-up your own configuration, context and graphicContext for StarsKit.

You can also decide of:

  • validateRatingButtonEnable: disable or enable the submit step rating. If disabled, the rate will be instantly submited after user touch.
  • useDefaultBehavior: disable the default StarsKit display checking behavior and implement your own in the StarsKitDelegate
  • priorityUseNativeRate: enable the native rating in iOS 10.3+, if not available, it will use the StarsKit screens 👌🏼
  • useSessionSpaceChecking: disable/enable the default checking of time elapsed between sessions. If enabled, when you update the session count, the session count will only be updated if the time between session is completely elapsed.. In others words, the user not enough uses the app for incrementing the session count. The same if you want to increment the session the same day than the last before, it will not be set.
  • localLocalizableStringsEnabled: enable the localization titles instead of configuration one. It will use the default StarKit strings. If you override them in your app localizable strings (with the same key), it will take them 😎.

StarsKitContext: update the metrics

To trigger the pop-up rating display, you have to update the metrics.

// Increment the number of crash, this will automatically update the last crash date (lastCrashDate)
StarsKit.shared.context.nbCrashes += 1

// Increment the session directly
StarsKit.shared.context.nbSessions += 1
// or
StarsKit.shared.incrementSession(by: 10)

// You can also reset all the app context values
StarsKit.shared.resetContext()

// You can also reset all the configuration properties
// After a new major version update for instance
StarsKit.shared.resetConfig()

You can also use the nbCrashes property with Fabric and Crashlytics:


extension AppDelegate {

  func setupFabricSDK(_ application: UIApplication) {
    Fabric.with([Crashlytics.self])
    Crashlytics.sharedInstance().delegate = self
  }
}

// MARK: - CrashlyticsDelegate
extension AppDelegate: CrashlyticsDelegate {
  func crashlyticsDidDetectReport(forLastExecution report: CLSReport) {
    StarsKit.shared.context.nbCrashes += 1
  }
}

See also StarsKitContextProperties for the user defaults properties.

Customization

Use StarsKitGraphicContext

Customizable items :

  • titles fonts
  • titles colors
  • button tintColor
  • button backgroundColor
  • header background image
  • ViewController presentation transition (via Jelly)
  • Stars style (via Cosmos)

Transitions & display (Jelly)

StarsKit uses Jelly fro customizable transitions. You can specify your own via the jellyCustomTransition property in the StarsKitGraphicContext.

StarsKitStarsKit

Go to Jelly repo for more information.

Stars (Cosmos)

Cosmos provides a CosmosSettings property that can be set in the StarsKitGraphicContext.

You specify your own stars images (filled/empty).
If nil, Cosmos will use the specified star path via starPoints.

StarsKit

Go to Comos repo for more information.

Step screens

  • Create the desired xib screen, with the same name than in StarsKit
  • Specify the custom class and the module as "StarsKit"
  • Uncheck "Inherit Module From Target"

IBOutlets are optionnals, so you can decide if you want to implement them or not.

StarsKit

StarsKit

Note: if you want to test it in the demo project, check the FeedbackViewController.xib in the StarsKit-Example target.

Override localizable strings

Simple add in your Localizable strings the localizable key(s) to override

See the default StarsKit.strings keys.

"starskit.mainTitle" = "My overrided title";

Override step controllers

StarsKitDelegate : listen to rating callbacks

// MARK: - StarsKitDelegate
extension ViewController: StarsKitDelegate {
  func didValidateRating(to rate: Int) {
    // Why not send an analytic ?
    print("Did validate rating to rate (rate)")
  }

  func didChooseAction(at step: RatingStep) {
    print("Did choose action button at step (step)")
  }

  func didChooseLater(at step: RatingStep) {
    print("Did choose later button at step (step)")
  }

  func needCustomDisplayRateScreen() -> Bool {
    //Implement your own behavior if you want
    return false
  }

  func didUpdateRating(from context: StarsKitContext, to rate: Int) {
    print("Did update rating at (rate)")
  }

}

StarsKitUIDelegate : listen to UI cycle events


// MARK: - StarsKitUIDelegate
extension ViewController: StarsKitUIDelegate {

  func didRatingScreenWillAppear() {
    print("didRatingScreenWillAppear")
  }

  func didRatingScreenDidAppear() {
    print("didRatingScreenDidAppear")
  }

  func didRatingScreenWillDisappear() {
    print("didRatingScreenWillDisappear")
  }

  func didRatingScreenDidDisappear() {
    print("didRatingScreenDidDisappear")
  }

  func presenterController() -> UIViewController {
    // Return the controller where the rate screen will be presented
    // The current, the top most one, anywhere, anyone
    return self
  }
}

Contributors

Made in 🇫🇷 by the Smart&Soft iOS Team.

License

StarsKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "StarsKit",
    "version": "0.1.0",
    "summary": "StarsKit is a Swift library to simplify, customize and configure your app rating workflow.",
    "homepage": "https://github.com/smartnsoft/StarsKit",
    "screenshots": [
        "https://github.com/smartnsoft/StarsKit/blob/master/img/step_rate.png",
        "https://github.com/smartnsoft/StarsKit/blob/master/img/step_feedback.png",
        "https://github.com/smartnsoft/StarsKit/blob/master/img/step_store.png"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Smart&Soft": "[email protected]"
    },
    "source": {
        "git": "https://github.com/smartnsoft/StarsKit.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/smartnsoft",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "StarsKit/Classes/**/*",
    "resources": [
        "StarsKit/Assets/*.lproj/*.strings",
        "StarsKit/Assets/StarsKitImages.xcassets"
    ],
    "frameworks": "UIKit",
    "dependencies": {
        "Cosmos": [
            "~> 15.0"
        ],
        "Extra/UIKit": [
            "~> 1.1"
        ],
        "Jelly": [
            "~> 1.2"
        ]
    }
}

Pin It on Pinterest

Share This