irate
- 給應(yīng)用做評(píng)價(jià)這個(gè)需求還是蠻普遍的,接下來就介紹下這個(gè)框架怎么應(yīng)用,以及自己在工作中的自己寫的類分享給大家。
- 我自己做了兩個(gè)版本,一個(gè)是irate自帶的彈框,不做改變,一個(gè)是對(duì)irate自帶的彈框的文字包括按鈕的點(diǎn)擊的效果做了變化,供大家參考。
irate原生彈框不做更改
- 圖片

原生彈框.png
- 代碼SCAppRateManager.h
#import <Foundation/Foundation.h>
/**
* app評(píng)分管理
*/
@interface SCAppRateManager : NSObject
#pragma mark -
+ (SCAppRateManager *)shareSCAppRateManager;
- (void)setup;
// 彈出評(píng)價(jià)提醒
+ (void)checkAndRate;
@end
- 代碼SCAppRateManager.m
#import "SCAppRateManager.h"
#import <iRate.h>
@interface SCAppRateManager () <iRateDelegate>
@end
@implementation SCAppRateManager
+ (SCAppRateManager *)shareSCAppRateManager
{
static SCAppRateManager *__instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
__instance = [[SCAppRateManager alloc] init];
});
return __instance;
}
- (void)setup
{
[iRate sharedInstance].delegate = self;
// 初始化Appstore id
[[iRate sharedInstance] setAppStoreID:您的appstoreID];
// 啟動(dòng)或者回到前臺(tái)就嘗試提醒
[iRate sharedInstance].promptAtLaunch = NO;
// 每個(gè)版本都彈
[iRate sharedInstance].promptForNewVersionIfUserRated = YES;
// 使用幾次后開始彈出
[iRate sharedInstance].usesUntilPrompt = 3;
// 多少天后開始彈出,默認(rèn)10次
[iRate sharedInstance].daysUntilPrompt = 3;
// 選擇“稍后提醒我”后的再提醒時(shí)間間隔,默認(rèn)是1天
[iRate sharedInstance].remindPeriod = 3;
[iRate sharedInstance].declinedThisVersion = NO;
}
+ (void)checkAndRate
{
if ([[iRate sharedInstance] shouldPromptForRating]) {
[[iRate sharedInstance] promptForRating];
}
}
- (void)iRateUserDidDeclineToRateApp
{
[iRate sharedInstance].lastReminded = [NSDate date];
}
@end
- 效果介紹:每個(gè)版本都會(huì)彈,使用三天后,至少使用三次后,彈出,選擇“稍后在說”、“不,謝謝”后,會(huì)在三天后再次彈出,選擇“去評(píng)價(jià)”會(huì)直接跳轉(zhuǎn)到appstore這個(gè)應(yīng)用的下載頁面,而后這個(gè)版本不再?gòu)棾?。下個(gè)版本,無論之前有沒有評(píng)價(jià),都會(huì)再次彈出。
irate自定義彈窗alert
- 圖片
自定義彈框.PNG
- AppRateManager.h代碼
#import <Foundation/Foundation.h>
/**
* app評(píng)分管理
*/
@interface AppRateManager : NSObject
#pragma mark -
+ (AppRateManager *)shareAppRateManager;
- (void)setup;
// 彈出評(píng)價(jià)提醒
- (void)checkAndRateWithController:(UIViewController *)VC;
@end
- AppRateManager.m代碼
#import "AppRateManager.h"
#import "iRate.h"
// 反饋界面
#import "LXRMineFeedBackViewController.h"
@interface AppRateManager ()<iRateDelegate>
@property (nonatomic, weak) UIViewController *VC;
@end
@implementation AppRateManager
+ (AppRateManager *)shareAppRateManager
{
static AppRateManager *__instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
__instance = [[AppRateManager alloc] init];
});
return __instance;
}
- (void)setup
{
[iRate sharedInstance].delegate = self;
// 初始化Appstore id
[[iRate sharedInstance] setAppStoreID:您的appstoreID];
// 啟動(dòng)或者回到前臺(tái)就嘗試提醒
[iRate sharedInstance].promptAtLaunch = NO;
// 每個(gè)版本都彈
[iRate sharedInstance].promptForNewVersionIfUserRated = YES;
// 使用幾次后開始彈出
[iRate sharedInstance].usesUntilPrompt = 3;
// 多少天后開始彈出,默認(rèn)10次
NSInteger firstRateAfterDays = 3;
// 選擇“稍后提醒我”后的再提醒時(shí)間間隔,默認(rèn)是1天
NSInteger interRateDays = 4;
[iRate sharedInstance].declinedThisVersion = NO;
NSString *rateTitle = @"給我評(píng)價(jià)";
NSString *rateText =@"覺得這個(gè)app怎么樣,喜歡就來評(píng)價(jià)一下唄";
[iRate sharedInstance].messageTitle = rateTitle;
[iRate sharedInstance].message = rateText;
[iRate sharedInstance].updateMessage = rateText;
[iRate sharedInstance].rateButtonLabel = @"喜歡,支持一下";
[iRate sharedInstance].remindButtonLabel = @"不喜歡,去吐槽";
[iRate sharedInstance].cancelButtonLabel = @"以后再說";
}
- (void)checkAndRateWithController:(UIViewController *)VC
{
self.VC = VC;
if ([[iRate sharedInstance] shouldPromptForRating]) {
[[iRate sharedInstance] promptForRating];
}
}
#pragma mark irateDelegate
-(void)iRateUserDidRequestReminderToRateApp
{
LXRMineFeedBackViewController *feedBackVC = [[LXRMineFeedBackViewController alloc] init];
[self.VC presentViewController:feedBackVC animated:YES completion:nil];
}
-(void)iRateUserDidDeclineToRateApp
{
[iRate sharedInstance].lastReminded = [NSDate date];
}
@end
- 效果介紹:彈框時(shí)間及條件跟原生irate相似。點(diǎn)擊“喜歡,支持一下”,去到appstore,點(diǎn)擊“不喜歡,去吐槽”,去到應(yīng)用內(nèi)反饋界面,點(diǎn)擊“以后再說”,三天后再次彈出。