GithubHelp home page GithubHelp logo

emland89 / swiftrater Goto Github PK

View Code? Open in Web Editor NEW

This project forked from takecian/swiftrater

0.0 0.0 0.0 612 KB

A utility that reminds your iPhone app's users to review the app written in pure Swift.

License: MIT License

Ruby 5.25% Objective-C 6.69% Swift 88.07%

swiftrater's Introduction

SwiftRater

Version License Build Status codebeat badge

SwiftRater is a class that you can drop into any iPhone app that will help remind your users to review your app on the App Store/in your app.

SwiftRater is written in pure Swift.

iOS 10.3 〜

SwiftRater1

For iOS 10.3 devices, SwiftRater uses SKStoreReviewController.

〜 iOS 10.2

SwiftRater2

macOS 10.14 〜

SwiftRater1

For macOS 10.14 devices, SwiftRater uses SKStoreReviewController.

〜 macOS 10.14

SwiftRater2

Requirements

iOS 8.0, macOS 10.10 or later, written in Swift. Xcode 8.2 or later.

Installation

Cocoapods

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

pod "SwiftRater"

Carthage

SwiftRater is compatible with Carthage. Add it to your Cartfile:

github "takecian/SwiftRater"

Usage

1.Setup SwiftRater in AppDelegate.swift. After setting up, call SwiftRater.appLaunched().

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        SwiftRater.daysUntilPrompt = 7
        SwiftRater.usesUntilPrompt = 10
        SwiftRater.significantUsesUntilPrompt = 3
        SwiftRater.daysBeforeReminding = 1
        SwiftRater.showLaterButton = true
        SwiftRater.debugMode = true
        SwiftRater.appLaunched()

        return true
    }

Property Description
daysUntilPrompt Shows review request if daysUntilPrompt days passed since first app launch.
usesUntilPrompt Shows review request if users launch more than usesUntilPrompt times.
significantUsesUntilPrompt Shows review request if user does significant actions more than significantUsesUntilPrompt

You can set properties you want to apply.

Property Description
debugMode Shows review request every time. Default false, need to set false when you submit app to AppStore.
conditionsMetMode Possible values: .any, .all (default)
Setting this to .any allows the prompt to be shown when any one or more of your criteria have been met.
showLaterButton Show Later button in review request dialong, valid for iOS10.2 or before devices.
daysBeforeReminding Days until reminder popup if the user chooses rate later, valid for iOS10.2 or before devices.

2.Call SwiftRater.check() in viewDidAppear of ViewController where you want to show review request dialog. If conditions are met, SwiftRater will show review request popup.

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        SwiftRater.check()
    }

3(Optional).For significantUsesUntilPrompt, you need to add SwiftRater.incrementSignificantUsageCount in siginificant action for your app.

func postComment() {
    // do something ..

	SwiftRater.incrementSignificantUsageCount()
}

4(Optional).Call SwiftRater.rateApp(host:) to let your users to review your app on the App Store/in your app directly.

func rateButtonDidClick(sender: UIButton) {
    // do something ..

	SwiftRater.rateApp(host: self)
}

Example

This example states that the rating request is only shown when the app has been launched 5 times and after 7 days, remind 5 days after if later selected.

SwiftRater.daysUntilPrompt = 7
SwiftRater.usesUntilPrompt = 5
SwiftRater.daysBeforeReminding = 5
SwiftRater.appLaunched()

If you wanted to show the request after 5 days only and remind 7 days after if later selected, you can set the following:

SwiftRater.daysUntilPrompt = 5
SwiftRater.daysBeforeReminding = 7
SwiftRater.appLaunched()

If you wanted to show the rquest after a user performs 10 significant actions before 5 days or 5 uses have passed:

SwiftRater.conditionsMetMode = .any
SwiftRater.daysUntilPrompt = 5
SwiftRater.usesUntilPrompt = 5
SwiftRater.significantUsesUntilPrompt = 10

Customize text

You can customize text in review request dialog for iOS10.2 or before devices. Set text in following properties.

  • SwiftRater.alertTitle
  • SwiftRater.alertMessage
  • SwiftRater.alertCancelTitle
  • SwiftRater.alertRateTitle
  • SwiftRater.alertRateLaterTitle
  • SwiftRater.appName

Country code

If your app is only avaiable for some coutnries, please add country code at Setup phase.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        SwiftRater.daysUntilPrompt = 7
        SwiftRater.usesUntilPrompt = 10

        SwiftRater.countryCode = "fr"

        SwiftRater.debugMode = true
        SwiftRater.appLaunched()
        return true
    }

App ID

Optional, you can set App ID explicitly. If not, SwiftRater will get App ID from appstore by bundle ID.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        SwiftRater.daysUntilPrompt = 7
        SwiftRater.usesUntilPrompt = 10

        SwiftRater.appID = "1104775712"

        SwiftRater.debugMode = true
        SwiftRater.appLaunched()
        return true
    }

Demo

You can find Demo app in this repo.

Author

takecian, [email protected]

License

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

swiftrater's People

Contributors

adeptusastartes avatar dependabot[bot] avatar emland89 avatar hyouuu avatar kf99916 avatar krezzoid avatar markgravity avatar nikans avatar takecian avatar tomwfox avatar wacumov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.