From eb25535dde9d03988b71812361decaa22866ca63 Mon Sep 17 00:00:00 2001 From: iLikeToMakeApps Date: Sat, 24 Dec 2016 11:39:34 +0100 Subject: [PATCH] add affiliate token and campaign --- Appirater.h | 3 +++ Appirater.m | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Appirater.h b/Appirater.h index 2ca0fab9..2c3db0ef 100644 --- a/Appirater.h +++ b/Appirater.h @@ -300,6 +300,9 @@ extern NSString *const kAppiraterReminderRequestDate; */ + (void)setAlwaysUseMainBundle:(BOOL)useMainBundle; ++ (void)setAffiliateToken:(NSString*)token; ++ (void)setAffiliateCampaign:(NSString*)campaign; + @end diff --git a/Appirater.m b/Appirater.m index de27b26d..24f9efe5 100644 --- a/Appirater.m +++ b/Appirater.m @@ -70,6 +70,8 @@ static UIStatusBarStyle _statusBarStyle; static BOOL _modalOpen = false; static BOOL _alwaysUseMainBundle = NO; +static NSString *_affiliateToken = nil; +static NSString *_affiliateCampaign = nil; @interface Appirater () @property (nonatomic, copy) NSString *alertTitle; @@ -161,6 +163,13 @@ + (void)setAlwaysUseMainBundle:(BOOL)alwaysUseMainBundle { _alwaysUseMainBundle = alwaysUseMainBundle; } ++ (void)setAffiliateToken:(NSString*)token { + _affiliateToken = token; +} ++ (void)setAffiliateCampaign:(NSString*)campaign{ + _affiliateCampaign = campaign; +} + + (NSBundle *)bundle { NSBundle *bundle; @@ -637,7 +646,14 @@ + (void)rateApp { SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init]; NSNumber *appId = [NSNumber numberWithInteger:_appId.integerValue]; - [storeViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:appId} completionBlock:nil]; + NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:appId forKey:SKStoreProductParameterITunesItemIdentifier]; + if (_affiliateToken != nil) { + [params setValue:_affiliateToken forKey:SKStoreProductParameterAffiliateToken]; + } + if (_affiliateCampaign != nil) { + [params setValue:_affiliateCampaign forKey:SKStoreProductParameterCampaignToken]; + } + [storeViewController loadProductWithParameters:params completionBlock:nil]; storeViewController.delegate = self.sharedInstance; id delegate = self.sharedInstance.delegate; @@ -666,6 +682,13 @@ + (void)rateApp { { reviewURL = [templateReviewURLiOS8 stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%@", _appId]]; } + + if (_affiliateToken) { + reviewURL = [reviewURL stringByAppendingFormat:@"&at=%@", _affiliateToken]; + } + if (_affiliateCampaign) { + reviewURL = [reviewURL stringByAppendingFormat:@"&ct=%@", _affiliateCampaign]; + } [[UIApplication sharedApplication] openURL:[NSURL URLWithString:reviewURL]]; #endif