使用 UIAlert 评价 5 星提醒

发布于 2024-10-02 13:25:12 字数 927 浏览 5 评论 0原文

我在网上搜索这个,但最终自己做到了。只需复制到viewdidload即可在应用程序第三次打开后显示提醒

NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
 NSString *documents = [path objectAtIndex:0];
 NSString *counterPath = [documents stringByAppendingPathComponent:@"counter.txt"];
 NSString *number = [NSString stringWithContentsOfFile:counterPath encoding:NSUTF8StringEncoding error:nil];
 int numberint = [number intValue];
 int opens = numberint + 1;
 NSString *dataString = [NSString stringWithFormat:@"%d", opens];
 NSData *data = [dataString dataUsingEncoding:NSUTF8StringEncoding];
 [data writeToFile:counterPath atomically:YES];


 if (opens == 3 ) {

  UIAlertView *myAlert = [[UIAlertView alloc]
        initWithTitle:@"*****" message:@"Please Rate 5 Stars to Support MY APP"
        delegate:self 
        cancelButtonTitle:nil
        otherButtonTitles:@"OK",nil];
  [myAlert show];
 }

I Was searchin the web for this but finaly made it by myself. Just copy to viewdidload to show the reminder after the app opened the third time

NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
 NSString *documents = [path objectAtIndex:0];
 NSString *counterPath = [documents stringByAppendingPathComponent:@"counter.txt"];
 NSString *number = [NSString stringWithContentsOfFile:counterPath encoding:NSUTF8StringEncoding error:nil];
 int numberint = [number intValue];
 int opens = numberint + 1;
 NSString *dataString = [NSString stringWithFormat:@"%d", opens];
 NSData *data = [dataString dataUsingEncoding:NSUTF8StringEncoding];
 [data writeToFile:counterPath atomically:YES];


 if (opens == 3 ) {

  UIAlertView *myAlert = [[UIAlertView alloc]
        initWithTitle:@"*****" message:@"Please Rate 5 Stars to Support MY APP"
        delegate:self 
        cancelButtonTitle:nil
        otherButtonTitles:@"OK",nil];
  [myAlert show];
 }

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

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

发布评论

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

评论(3

爱的故事 2024-10-09 13:25:12

您应该使用 NSDefaults 来存储计数器值,而不是使用文本文件,并在启动时读取它。它会大大简化代码。

instead of using text file, you should have used NSDefaults to store the counter value, and just read it on launch. It would have simplified the code a lot.

空袭的梦i 2024-10-09 13:25:12

与其构建自己的解决方案,为什么不使用现成的库来执行此操作呢?

例如这个;-): https://github.com/nicklockwood/iRate

这可以让你配置何时根据应用程序启动次数、安装天数和一堆其他参数显示评级提示,并将用户直接带到 iTunes 上的评级页面。

Rather than build your own solution, why not use an off-the-shelf library to do this?

Like this one for example ;-): https://github.com/nicklockwood/iRate

This lets you configure when the rating prompt will be shown based on number of app launches, number of days installed and a bunch of other parameters, and it takes the user directly to the ratings page on iTunes.

终难愈 2024-10-09 13:25:12

Appirater 是一个类,您可以将其放入任何 iPhone 应用程序(iOS 4.0 或更高版本)中,以帮助提醒您的用户在 App Store 上评论您的应用程序。该代码是在 MIT/X11 下发布的,因此请随意修改并与世界分享您的更改。请阅读下文了解如何开始。如果您需要任何使用帮助,请查看图书馆的 Appirater 小组。

Configuration

Appirater 提供类方法来配置其行为。有关详细信息,请参阅 Appirater.h。

[Appirater setAppId:@"552035781"];
[Appirater setDaysUntilPrompt:1];
[Appirater setUsesUntilPrompt:10];
[Appirater setSignificantEventsUntilPrompt:-1];
[Appirater setTimeBeforeReminding:2];
[Appirater setDebug:YES];

Appirater is a class that you can drop into any iPhone app (iOS 4.0 or later) that will help remind your users to review your app on the App Store. The code is released under the MIT/X11, so feel free to modify and share your changes with the world. Read on below for how to get started. If you need any help using, the library check out the Appirater group.

Configuration

Appirater provides class methods to configure its behavior. See Appirater.h for more information.

[Appirater setAppId:@"552035781"];
[Appirater setDaysUntilPrompt:1];
[Appirater setUsesUntilPrompt:10];
[Appirater setSignificantEventsUntilPrompt:-1];
[Appirater setTimeBeforeReminding:2];
[Appirater setDebug:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文