ios 如何在我的应用中添加“写评论”/“评价我们”功能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6736189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:48:38  来源:igfitidea点击:

How to Add "Write a Review" / "Rate Us" Feature to My App?

iosuiwebviewpopupreviewrate

提问by Ohad Regev

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:

我能想到的最佳实践是在我的应用程序中使用某种弹出窗口或打开一个 UIWebView,这样用户在打开 App Store 应用程序时不会像在下面那样从我的应用程序中退出:

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

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

Does anyone knows of a way to do that?

有谁知道这样做的方法?

回答by Sam Spencer

StoreKit API (iOS 10.3 and up)

StoreKit API(iOS 10.3 及更高版本)

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:

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

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

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

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 viewDidAppearcall, 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.

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

如果您没有做到这一点并且只是将评论提示放在任何地方(viewDidAppear例如一个电话),您的用户将会相当恼火,因为他们会很快且反复看到它。然后,要么他们留下差评(因为他们很生气),要么一整年都没有被要求再次评论。

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

以下是警报外观的示例。有关更多信息,请参阅Apple 的文档

StoreKit rating / review prompt.

StoreKit 评级/评论提示。



iRate (iOS 7.0 and up)

iRate(iOS 7.0 及更高版本)

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

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

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 uialertviewand storekitto 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.

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

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.

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

Setup

设置

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

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

  1. Import the header in your AppDelegate: #import "iRate.h"
  2. Add the StoreKitFramework 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;
    
  1. 在 AppDelegate 中导入标头: #import "iRate.h"
  2. StoreKit框架添加到您的项目 - Apple 文档中有关StoreKit 的更多信息
  3. 在您的application: didFinishLaunchingWithOptions:方法中,设置以下内容:

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

Properties

特性

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

以下属性可用于测试目的。YES在测试期间将其设置为以确保对话框正确显示。设置为YES它会在启动时立即出现,而不管其他显示设置。将此设置NO为应用程序的发布版本。

 [iRate sharedInstance].previewMode = NO;

The appStoreIDproperty 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:

appStoreID属性允许您设置应用程序的 ID。这是,如果你有同样的捆绑标识符Mac和iOS应用才需要。此处设置的 App ID 还必须与 Xcode 和 iTunes Connect 中设置的 Bundle ID 匹配:

[iRate sharedInstance].appStoreID = 555555555;

More Detailsare available on the iRate GitHub page.

更多详细信息可在 iRate GitHub 页面上找到。

回答by Zebs

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

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

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

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