/StanwoodDialog_iOS

An app rating dialog framework that links to the iTunes AppStore.

Primary LanguageSwiftMIT LicenseMIT

StanwoodDialog

Swift Version iOS 10.3+ Pod Version Maintainability Build Status License Build Status Docs

Example

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

Installation

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

pod 'StanwoodDialog'

Usage

Add import StanwoodDialog and call the method bellow from wherever you are calling AppDelegate's applicationDidBecomeAvailable: If you wish to specify your string locally, you can add them here

    RatingDialog.builder()
            .set(paragraph1: "text1")
            .set(paragraph2: "text2")
            .set(paragraph3: "text3")
            .set(paragraph4: "text4")
            .set(cancelText: "cancel")
            .set(okText: "accept")
            .set(faceUrl: "faceUrlString")
            .set(bannerUrl: "bannerUrlString")
            .set(tintColor: .blue)
            .set(appID: "284815942")
            .set(rootView: UIApplication.shared.keyWindow!)
            .buildAndShowIfNeeded { (state) in
                
                        switch state {
                        case .didCancel:
                            print("didCancel")
                        case .didShowInitialRateMe:
                            print("didShowInitialRateMe")
                        case .didShowAppleReviewController:
                            print("didShowAppleReviewController")
                        case .didSendToStore:
                            print("didSendToStore")
                        }
                
            }

Ideally you would be fetching each one of these parameters remotely. For instance, from Firebase RemoteConfig to do some A/B testing and/or from a service like lokalise.co to provide internationalization.

If you want to use values direct from Firebase RemoteConfig, you can use the rquired keys below to clean up your code.

With completion, as little as:

    RatingDialog.builder().buildAndShowIfNeeded { (state) in
        
                switch state {
                case .didCancel:
                    print("didCancel")
                case .didShowInitialRateMe:
                    print("didShowInitialRateMe")
                case .didShowAppleReviewController:
                    print("didShowAppleReviewController")
                case .didSendToStore:
                    print("didSendToStore")
                }
        
    }

Without completion:

    RatingDialog.builder().buildAndShowIfNeeded()

Required RemoteConfig keys

"ios_app_id" - ID od application in the store
"rate_dialog_text" - First line of text
"rate_dialog_text_2" - Second line of text
"rate_dialog_text_3" - Third line of text
"rate_dialog_text_4" - Fourth line of text
"rate_dialog_launch_count" - Number of launches required until dialog is shown
"rate_dialog_face_url" - Url string to load a face image
"rate_dialog_banner_url" - Url string to load a banner image
"rate_dialog_cancel_button" - Cancel button title
"rate_dialog_ok_button" - Ok button title

When using the RemoteConfig keys, ensure your config is set before initialising the dialog, otherwise the values will be wrong

If you don't have a URL for the profile and banner images, you may upload these to Firebase Storage (go to Store section in Firebase and click on [Upload Image]):

  • the profile image should be 300x300 pixels (this will cover the 3 variations for 100x100 points)
  • the banner image should be 300x1125 pixels (this will cover the 3 variations for 100x375 points)

Test

Using a negative value in RatingDialog.shouldShow(onLaunch: -1) will result in the Rating Dialog being shown everytime.

Also, while in Debug, the launch count doesn't need 30 minutes from the last launch to increase its count.

Author

Eugène Peschard, eugene.peschard@stanwood.io

License

StanwoodDialog is under MIT licence. See the LICENSE file for more info.