Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add affiliate token and campaign #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Appirater.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ extern NSString *const kAppiraterReminderRequestDate;
*/
+ (void)setAlwaysUseMainBundle:(BOOL)useMainBundle;

+ (void)setAffiliateToken:(NSString*)token;
+ (void)setAffiliateCampaign:(NSString*)campaign;

@end


Expand Down
25 changes: 24 additions & 1 deletion Appirater.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <AppiraterDelegate> delegate = self.sharedInstance.delegate;
Expand Down Expand Up @@ -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
Expand Down