RateMe
获得五星评价对于每个应用程序来说都非常重要。RateMe可以帮助您跟踪用户,并在用户满意时提醒您。
安装
RateMe可通过CocoaPods获得。要安装,只需将以下行添加到您的Podfile
pod 'RateMe'
线程安全
RateMe使用GCD避免阻塞UI。RateMe使用串行GCD队列以避免竞争条件。
用法
示例1
假想您想提醒那些打开产品详情页面4次的用户。
在AppDelegate中初始化RateMe
#import <RateMe/RateMe.h>
@interface ZngAppDelegate()<RateMeDelegate>
@end
@implementation ZngAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//VisitDetailPage is the triggerName
[[RateMe sharedInstance] addConditionWithName:@"VisitDetailPage" count:4];
[RateMe sharedInstance].delegate = self;
return YES;
}
-(void)onRateMeTime{
[SKStoreReviewController requestReview];
}
@end
在ProductDetailViewController的viewDidLoad中发送触发器到RateMe
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//use the same name for the trigger
[[RateMe sharedInstance] trigger:@"VisitDetailPage"];
}
示例2
假设您想要警告那些打开产品详情页4次或登录一次的用户。
在AppDelegate中初始化RateMe
#import <RateMe/RateMe.h>
@interface ZngAppDelegate()<RateMeDelegate>
@end
@implementation ZngAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[RateMe sharedInstance] addConditionWithName:@"VisitDetailPage" count:4];
[[RateMe sharedInstance] addConditionWithName:@"Login" count:1];
[RateMe sharedInstance].delegate = self;
return YES;
}
-(void)onRateMeTime{
[SKStoreReviewController requestReview];
}
@end
在ProductDetailViewController的viewDidLoad中发送触发器到RateMe
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[RateMe sharedInstance] trigger:@"VisitDetailPage"];
}
当用户登录时发送触发器到RateMe
[[RateMe sharedInstance] trigger:@"Login"];
您可以使用addConditionWithName、addConditionWithNameList或addCondition方法添加无限或陈述。
示例 3
当某些触发器的总数达到所需数量时,可以使用带有名称列表的 addCondition 方法。
#import <RateMe/RateMe.h>
@interface ZngAppDelegate()<RateMeDelegate>
@end
@implementation ZngAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[RateMe sharedInstance] addConditionWithNameList:@[@"trigger1", @"trigger2"] count:5];
[RateMe sharedInstance].delegate = self;
return YES;
}
-(void)onRateMeTime{
[SKStoreReviewController requestReview];
}
@end
当 trigger1 和 trigger2 的总数达到 5 时,将调用 onRateMe 事件。
示例 4
对于 AND 条件,您需要自己创建条件。
#import <RateMe/RateMe.h>
@interface ZngAppDelegate()<RateMeDelegate>
@end
@implementation ZngAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
RateMeCondition *condition1 = [RateMeCondition rateMeConditionWithTriggerName:@"trigger1" count:3];
RateMeCondition *condition2 = [RateMeCondition rateMeConditionWithTriggerName:@"trigger2" count:4];
RateMeCondition *condition3 = [RateMeCondition rateMeConditionWithTriggerNameList:@[@"trigger3", @"trigger4" , @"trigger5"] count:5];
RateMeCondition *andConditions = [RateMeCondition rateMeConditionWithConditionList:@[condition1, condition2, condition3]];
[[RateMe sharedInstance] addCondition:andConditions];
[RateMe sharedInstance].delegate = self;
return YES;
}
-(void)onRateMeTime{
[SKStoreReviewController requestReview];
}
@end
当 trigger1 发生 3 次、trigger2 发生 4 次以及 trigger3、trigger4 和 trigger5 发生的总次数达到 5 时,将调用 onRateMe 事件。
更改延迟时间
当触发器数量达到所需数量时,RateMe 将在调用 onRateMeTime 方法之前等待几秒钟(默认为 10 秒)。如果您想更改此持续时间;
[RateMe sharedInstance].delayDuration = 5; //now delayDuration is 5 seconds
作者
移动团队 Zingat
- 卡迪尔·卡马尔·杜尔逊,https://github.com/KadirKemal
许可
RateMe 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。