Skip to content

Tiny lib to show "Rate my app" alert for macOS and iOS apps.

License

Notifications You must be signed in to change notification settings

ukushu/IAppRater

Repository files navigation

IAppRater

Tiny lib to show "Rate my app" alert for macOS and iOS apps.

SupportedOS:

iOS(?), MacOS(>=12)

KeyFeatures:

  • Ability to set minimal amount of app launches before yout app perform request to rate your app
  • --//-- minimum days of usage --//--
  • Do not ask to rate your app if this version already was rated by user
  • Ability to open standard "Rate Me" alert OR open "Rate me" popup inside of AppStore window
  • Ability to work with custom View logic like "Show "Rate my app" button only if rate is needed"
  • Ability to set additional custom rules for "rate is needed" state :)

How to use, sample with SwiftUI:

//init custom AppDelegate

import SwiftUI

@main
struct FocusitoApp: App {
    @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
    var body: some Scene {
        MainView()
    }
}

//init AppRater on DidFinishLaunching inside of AppDelegate

class AppDelegate: NSObject, NSApplicationDelegate {
    static var shared: AppDelegate!
    
    var appRater: IAppRater!
    
    func applicationDidFinishLaunching(_ notification: Notification) {
        AppDelegate.shared = self
        
        // if we do not need custom display alert logic
        //appRater = IAppRater(minLaunches: 10,
        //                     minDays: 15,
        //                     rateWndType: .standardAlert
        //)
        
        // if we need custom display logic
        appRater = IAppRater(minLaunches: 10,
                             minDays: 15,
                             other: { _ in Stats.shared.sessions.count > 100 },
                             rateWndType: .standardAlert
        )
        
        // if we need to show request on app run:
        // appRater.requestIfNeeded()
        // and other code does not needed
    }
}

// We can locate button to open some panel

struct MainView : View {
    var body: some View {
        VStack {
            MyMainViewBody()
            
            if AppDelegate.shared.appRater.isNeededToRate() {
                Button("Rate my app") { model.showBottomPanel.toggle() }
            } 
        }
    }
}

// We can locate button to show "Rate my app" alert

struct MainView : View {
    var body: some View {
        VStack {
            MyMainViewBody()
            
            if AppDelegate.shared.appRater.isNeededToRate() {
                Button("Rate my app") { AppDelegate.shared.appRater.requestIfNeeded() }
            } 
        }
    }
}

// We can open standard OS's alert

// Or we can call appStore's alert "Rate my app"

appRater = IAppRater(...., rateWndType: .appStoreWnd(appId: "1473808464") )

Extra custom logic for display panel witn "Rate My App" button:

appRater = IAppRater(minLaunches: 2,
                     minDays: 2,
                     other: { me in // 0
                        (MainViewModel.shared.appState == .Idle || MainViewModel.shared.appState == .Paused) && // 1
                            Stats.shared.sessions.map{ $0.duration }.sum() > TimeInterval(hrs: 5) && // 2
                            me.lastReviewDate == nil // 3
                     },
                     rateWndType: .appStoreWnd(appId: "1473808464")
                    )
    • min app launches = 2
    • min days after first app launch = 3
  • 0 - me = input of IAppRater's "self" for using some properties if needed for some custom purposes with them
  • 1 - if application state is .idle or .paused
  • 2 - if some sessions duration is larger than 5 hrs
  • 3 - if user have never did rate the app. But if he is rated at least once - never show "rate app" button to user

if you need to debug your "isNeededToRate()" value - you able to set input parameter

🇺🇦🇺🇦🇺🇦 UKRAINE NEEDS YOUR SUPPORT! 🇺🇦🇺🇦🇺🇦

Mariupol city before Russia invasion (2021):

Mariupol city after Russia invasion (2022):

( ruined almost all infrastructure )

Destruction of the Kakhovka Dam

Russia destroyed Kakhovka Dam in the early hours of 6 June 2023 in Kherson Oblast. This was the second-largest reservoir in Ukraine by area (2,155 km2 [832 sq mi]) and the largest by water volume (18.19 km3 [4.36 cu mi]). According to Ukrainian military intelligence, Russian forces carried out "major mining" of the Kakhovka dam shortly after taking control in February 2022, and in April 2022 mined locks and supports and installed "tented trucks with explosives on the dam itself". In October 2022, the Foreign Minister of Moldova, Nicu Popescu, said that Ukraine had intercepted Russian missiles targeting a different dam, on the Dniester river. At the time, Ukrainian president Zelenskyy warned of Russian preparations to destroy the Kakhovka dam and blame Ukraine, and called for an international observation mission at the dam to prevent a potential catastrophe.

The capacity of the Kakhovka reservoir was 18 million cubic meters of fresh water.

This reservoir could have provided all people on the planet with fresh water for more than 2 years. And this water was lost.

Not to mention the flooded residential areas and the environmental disaster caused by the washing away of cemeteries and desalination of water in the Black Sea.