如何添加“撰写评论” /“给我们评分”我的应用程序的功能?

发布于 2024-11-25 03:48:47 字数 305 浏览 1 评论 0原文

我希望在我的应用程序中添加某种“撰写评论”或“给我们评分”功能,以便我的客户可以轻松地对我的应用程序进行评分和评论。

我能想到的最佳实践是在我的应用程序中进行某种弹出窗口或打开 UIWebView,这样用户在打开 App Store 应用程序时就不会被踢出我的应用程序,如下所示:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/myAppName"]];

有谁知道如何做到这一点?

I wish to add some sort of a "Write a Review" or "Rate Us" feature to my app so my customers can easily rate and review my app.

Best practice I can think of is to have some sort of pop-up or open a UIWebView within my app so the user is not kicked off of my app while opening the App Store application as done in:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/myAppName"]];

Does anyone knows of a way to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

懒猫 2024-12-02 03:48:47

StoreKit API(iOS 10.3 及更高版本)

从 iOS 10.3 开始,StoreKit API 提供了一种无需离开应用程序即可在 App Store 上请求审核的方法。当被调用时,系统可能会向用户显示请求审查的警报。用户可以直接在警报内提供星级,继续撰写评论,或关闭警报。 StoreKit 几乎可以为您处理所有事情。要提出评论请求,请在应用程序中适当的位置进行以下调用:

// Objective-C
[SKStoreReviewController requestReview]

// Swift
SKStoreReviewController.requestReview()

根据 Apple 的说明,您不应调用这些来响应直接用户交互(即点击显示“撰写评论”的按钮),因为它可能并不总是显示警报。事实上,该警报每 365 天只能显示 3 次。

重要提示:虽然这看起来相当简单,但您仍然需要编写某种逻辑来间隔提示。例如,仅在 X 次启动、X 天或重大事件后才显示提示。

如果您未能做到这一点,而只是将审阅提示粘贴在任何地方(例如,viewDidAppear 调用),您的用户将会相当恼火,因为他们会很快且重复地看到它。然后,他们要么留下差评(因为他们很恼火),要么整整一年都没有被要求再次评论。

下面是警报的示例。有关详细信息,请参阅 Apple 文档

StoreKit 评级/ 审核提示。


iRate(iOS 7.0 及更高版本)

如果您的应用在早于 10.3 的 iOS 版本上运行或者,您需要对请求用户评分进行更强大的控制, iRate 是一个很好的解决方案。

对于运行 iOS 10.3 或更高版本的设备,iRate 使用上述 StoreKit API。对于运行 iOS 7.0 到 10.2 的设备,iRate 使用 询问用户评级(或稍后提醒他们)。从“取消”按钮的标题到提醒用户的时间间隔,一切都是可定制的。

默认情况下,iRate 在满足某些要求时自动打开(例如应用程序启动 X 次、用户通过 X 级),但您也可以使用各种方法和您自己的逻辑(借助 iRate 方法)来打开手动显示 iRate 弹出窗口。

安装

要安装,只需将头文件、实现文件和 .bundle(用于本地化)拖到您的项目中。

  1. 在您的 AppDelegate 中导入标头:#import "iRate.h"
  2. StoreKit 框架添加到您的项目中 - 更多信息请参阅 Apple 文档中的 StoreKit
  3. 在您的 应用程序中: didFinishLaunchingWithOptions: 方法,设置以下内容:

    // 配置 iRate
    [iRate共享实例].daysUntilPrompt = 5;
    [iRate共享实例].usesUntilPrompt = 15;
    

属性

下面的属性对于测试目的很有用。在测试期间将其设置为 YES 以确保对话框正确显示。当设置为 YES 时,它将在启动时立即出现,忽略其他显示设置。对于应用的发布版本,将此设置为 NO

 [iRate sharedInstance].previewMode = NO;

appStoreID 属性允许您设置应用程序的 ID。 仅当您的 Mac 和 iOS 应用程序具有相同的捆绑包标识符时才需要。此处设置的 App ID 还必须与 Xcode 和 iTunes Connect 中设置的 Bundle ID 相匹配:

[iRate sharedInstance].appStoreID = 555555555;

提供更多详细信息在 iRate GitHub 页面上。

StoreKit API (iOS 10.3 and up)

As of iOS 10.3, the StoreKit API provides a way to request a review on the App Store without leaving your app. When called, the system may present the user with an alert that requests a review. The user may provide a star rating directly inside the alert, continue on to write a review, or dismiss the alert. StoreKit handles just about everything for you. To present the review request, make the following call where it is appropriate in your app:

// Objective-C
[SKStoreReviewController requestReview]

// Swift
SKStoreReviewController.requestReview()

As per Apple's instructions, you should not call these in response to a direct user-interaction (i.e. tapping a button that says "Write a Review") because it may not always display the alert. Indeed, the alert may only be displayed three times every 365 days.

Important Note: Although this seems fairly simple, you'll still need to write some kind of logic in order to space out your prompts. For example, to present the prompt only after X number of launches, days, or significant events.

If you fail to do this and just stick the review prompt anywhere (a viewDidAppear call, for example), your users will be rather annoyed because they'll see it pretty quickly and repeatedly. Then, either they leave a bad review (because they're annoyed) or aren't asked to review again for a whole year.

Below is an example of what the alert looks like. For more information, see Apple's documentation.

StoreKit rating / review prompt.


iRate (iOS 7.0 and up)

If your app runs on versions of iOS earlier than 10.3 or you need more robust control over requesting ratings from users, iRate is a good solution.

For devices with iOS 10.3 or greater, iRate uses the aforementioned StoreKit API. For devices running iOS 7.0 to 10.2, iRate uses a and to ask the user for a rating (or to remind them later). Everything is customizable, from the title of the Cancel button to the interval at which it reminds the user.

By default, iRate automatically opens when certain requirements are met (e.g. app launched X number of times, user passed X number of levels), but you can also use a variety of methods and your own logic (with the help of iRate methods) to manually display an iRate popup.

Setup

To install, just drag the header file, the implementation file, and the .bundle (for localization) into your project.

  1. Import the header in your AppDelegate: #import "iRate.h"
  2. Add the StoreKit Framework to your project - More on StoreKit from Apple Documentation
  3. In your application: didFinishLaunchingWithOptions: method, set the following:

    // Configure iRate
    [iRate sharedInstance].daysUntilPrompt = 5;
    [iRate sharedInstance].usesUntilPrompt = 15;
    

Properties

The property below is useful for testing purposes. Set it to YES during testing to make sure the dialog appears properly. When set to YES it will appear immediately on startup, disregarding other display settings. Set this to NO for release versions of your app.

 [iRate sharedInstance].previewMode = NO;

The appStoreID property allows you to set the ID of your app. This is only required if you have both Mac and iOS apps with the same Bundle Identifier. The App ID set here must also match the Bundle ID set in Xcode and iTunes Connect:

[iRate sharedInstance].appStoreID = 555555555;

More Details are available on the iRate GitHub page.

Hello爱情风 2024-12-02 03:48:47

我使用的一个非常好的 Appirater:https://github.com/arashpayan/appirater/

它自动提示您的用户留下评论,您只需提供您的应用 ID。

A really good one I use is Appirater: https://github.com/arashpayan/appirater/

It automatically prompts your users to leave reviews, you just have to provide your app id.

稀香 2024-12-02 03:48:47

输入图片此处描述声明变量

let reviewService = ReviewService.shared

在视图中出现

self.reviewService.rateAlert(from: self)

导入类

import UIKit
import StoreKit

class ReviewService: NSObject {
    
    static let shared = ReviewService()
    
    private var lastRequest : Date? {
        
        get {
            
            return UserDefaults.standard.value(forKey: "lastRequest") as? Date
        }
        set {
            
            UserDefaults.standard.set(newValue, forKey: "lastRequest")
        }
    }
    
    private var oneDayAgo : Date {
        
        return Calendar.current.date(byAdding: .day, value: -1, to: Date()) ?? Date()
    }
    
    private var shouldReview : Bool {
        if lastRequest == nil {
            return true
        }
        else if let lastRequest = self.lastRequest , lastRequest < oneDayAgo {
            return true
        }
        else {
            
            return false
        }
    }
    
    func requestReview(isWrittenReview : Bool = false) {
        
        if isWrittenReview {
            let appID = "##########" // App Id
            
            let urlStr = "https://itunes.apple.com/app/id\(appID)?action=write-review"
            
            guard let url = URL(string: urlStr), UIApplication.shared.canOpenURL(url) else { return }
            
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }
        else {
            SKStoreReviewController.requestReview()
        }
        
    }
    
    //MARK:- Rate App
    func rateAlert(from : UIViewController?) {
        
        guard shouldReview else {
            print("Don't Show")
            return
        }
        
        guard let vc = from else {
            
            return
        }
        
        lastRequest = Date()
        
        let alert = UIAlertController(title: "Rate our App", message: "If you love our app, please take a moment to rate it in the App Store", preferredStyle: .alert)
        
        
        let action1 = UIAlertAction(title: "Rate", style: .default, handler: {(_ action: UIAlertAction?) -> Void in
            
            self.requestReview(isWrittenReview: false)
            
        })
        
        let action2 = UIAlertAction(title: "Send Feedback", style: .default, handler: {(_ action: UIAlertAction?) -> Void in
            
            self.requestReview(isWrittenReview: true)
            
        })
        
        let action3 = UIAlertAction(title: "Close", style: .default, handler: nil)
        
        alert.addAction(action1)
        alert.addAction(action2)
        alert.addAction(action3)
        vc.present(alert,animated: true)
        
    }
    }

enter image description hereDeclare Variable

let reviewService = ReviewService.shared

In View Did Appear

self.reviewService.rateAlert(from: self)

Import the Class

import UIKit
import StoreKit

class ReviewService: NSObject {
    
    static let shared = ReviewService()
    
    private var lastRequest : Date? {
        
        get {
            
            return UserDefaults.standard.value(forKey: "lastRequest") as? Date
        }
        set {
            
            UserDefaults.standard.set(newValue, forKey: "lastRequest")
        }
    }
    
    private var oneDayAgo : Date {
        
        return Calendar.current.date(byAdding: .day, value: -1, to: Date()) ?? Date()
    }
    
    private var shouldReview : Bool {
        if lastRequest == nil {
            return true
        }
        else if let lastRequest = self.lastRequest , lastRequest < oneDayAgo {
            return true
        }
        else {
            
            return false
        }
    }
    
    func requestReview(isWrittenReview : Bool = false) {
        
        if isWrittenReview {
            let appID = "##########" // App Id
            
            let urlStr = "https://itunes.apple.com/app/id\(appID)?action=write-review"
            
            guard let url = URL(string: urlStr), UIApplication.shared.canOpenURL(url) else { return }
            
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }
        else {
            SKStoreReviewController.requestReview()
        }
        
    }
    
    //MARK:- Rate App
    func rateAlert(from : UIViewController?) {
        
        guard shouldReview else {
            print("Don't Show")
            return
        }
        
        guard let vc = from else {
            
            return
        }
        
        lastRequest = Date()
        
        let alert = UIAlertController(title: "Rate our App", message: "If you love our app, please take a moment to rate it in the App Store", preferredStyle: .alert)
        
        
        let action1 = UIAlertAction(title: "Rate", style: .default, handler: {(_ action: UIAlertAction?) -> Void in
            
            self.requestReview(isWrittenReview: false)
            
        })
        
        let action2 = UIAlertAction(title: "Send Feedback", style: .default, handler: {(_ action: UIAlertAction?) -> Void in
            
            self.requestReview(isWrittenReview: true)
            
        })
        
        let action3 = UIAlertAction(title: "Close", style: .default, handler: nil)
        
        alert.addAction(action1)
        alert.addAction(action2)
        alert.addAction(action3)
        vc.present(alert,animated: true)
        
    }
    }
荆棘i 2024-12-02 03:48:47

您可以使用我的 SKStoreReviewController 小型包装器。

// Review after 3 launches
AppReview.requestIf(launches: 3)

// Review after 5 days
AppReview.requestIf(days: 5)

// Review after 3 launches and 5 days
AppReview.requestIf(launches: 3, days: 5)

https://github.com/mezhevikin/AppReview

You can use my tiny wrapper around SKStoreReviewController.

// Review after 3 launches
AppReview.requestIf(launches: 3)

// Review after 5 days
AppReview.requestIf(days: 5)

// Review after 3 launches and 5 days
AppReview.requestIf(launches: 3, days: 5)

https://github.com/mezhevikin/AppReview

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文