Coder Social home page Coder Social logo

ukushu / iapprater Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 104 KB

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

License: MIT License

Swift 100.00%
appreview appstore ios macos macosx rate-app rate-app-api rating rating-stars request review reviews stars storekit storekit2 swift swiftui

iapprater's Introduction

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.

iapprater's People

Contributors

ukushu avatar

Watchers

 avatar  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.