In-app ratings for Cocoa apps

In-app Ratings module helps improve app rating by allowing you to customize the appropriate location and time for prompting users to rate your application. Refer to this user guide to configure in-app ratings in the Apptics web console.

Installation

Copiedsource 'https://github.com/CocoaPods/Specs.git'

target '[TARGET NAME]' do
  pod 'AppticsRateUs'
end

Run the pod install to integrate the module.

Import

Copied#import <AppticsRateUs/AppticsRateUs.h>
Copiedimport AppticsRateUs

Dynamic in-app ratings

In dynamic in-app ratings, you can configure the criteria using screens, events, and sessions in the Apptics web console. A rate us pop-up will be shown to the user whenever the criteria are satisfied.

  • Enable the Rate us module by using Apptics config class AppticsConfig.default.enableRateUs=true.
Copied[AppticsConfig defaultConfig].enableRateUs = true;
[Apptics initializeWithVerbose:YES];

CopiedAppticsConfig.default.enableRateUs = true
Apptics.initialize(withVerbose: true)

To handle in-app ratings, create a custom class that conforms to the ARCustomHandler protocol. For example:

Copied@interface CustomHandler : NSObject <ARCustomHandler>
@end
Copiedclass CustomHandler: NSObject, ARCustomHandler {}

Pass the instance of your custom handler to ARCustomHandlerManager

Copied[ARCustomHandlerManager setCustomHandler:[CustomHandler new]];
CopiedARCustomHandlerManager.setCustomHandler(CustomHandler())

willDisplayReviewPrompt

Use the callback method to show the review popup.

Implement and register a custom handler using ARCustomHandler.

Copied#import <AppticsRateUs/AppticsRateUs.h>
#import <StoreKit/StoreKit.h>

@interface CustomHandler : NSObject <ARCustomHandler>
@end

@implementation CustomHandler

- (void)willDisplayReviewPrompt {
    //You could show AppStore Review popup or any custom review
    [self showAppStoreReview]; 
}

- (void)showAppStoreReview {
    if (@available(iOS 10.3, *)) {
#if TARGET_OS_IOS
        dispatch_async(dispatch_get_main_queue(), ^{
            if (@available(iOS 14.0, *)) {
                for (UIWindowScene *windowScene in [UIApplication sharedApplication].connectedScenes) {
                    if (windowScene.activationState == UISceneActivationStateForegroundActive ||
                        windowScene.activationState == UISceneActivationStateForegroundInactive) {
                        [SKStoreReviewController requestReviewInScene:windowScene];
                        break;
                    }
                }
            } else {
                [SKStoreReviewController requestReview];
            }
        });
#endif
    } else {
        //Fallback Popup
    }
}

@end

//Call this method while initialising Apptics 
[ARCustomHandlerManager setCustomHandler:[CustomHandler new]];
Copiedimport AppticsRateUs
import StoreKit
import UIKit

class CustomHandler: NSObject, ARCustomHandler {
    
    func willDisplayReviewPrompt() {
        //You could show AppStore Review popup or any custom review
        showAppStoreReview() 
    }
    
    func showAppStoreReview() {
        if #available(iOS 10.3, *) {
            DispatchQueue.main.async {
                if #available(iOS 14.0, *) {
                    if let windowScene = UIApplication.shared.connectedScenes
                        .compactMap({ $0 as? UIWindowScene })
                        .first(where: { $0.activationState == .foregroundActive || $0.activationState == .foregroundInactive }) {
                        SKStoreReviewController.requestReview(in: windowScene)
                    }
                } else {
                    SKStoreReviewController.requestReview()
                }
            }
        } else {
            //Fallback UI
        }
    }

}

//Call this method while initialising Apptics 
ARCustomHandlerManager.setCustomHandler(CustomHandler())

For SwiftUI

Copiedimport SwiftUI

class CustomHandler : NSObject, ARCustomHandler {

   @Environment(\.requestReview) private var requestReview   

   private func presentReview() {

       Task {

           // Delay for two seconds to avoid interrupting the person using the app.

           try await Task.sleep(for: .seconds(2))

           await requestReview()

       }

   }

   func willDisplayReviewPrompt() {

       presentReview()      

   }   

}

//Call this method while initialising Apptics

ARCustomHandlerManager.setCustomHandler(CustomHandler())