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

better localization handle #197

Open
wants to merge 3 commits 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
2 changes: 1 addition & 1 deletion Appirater.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ extern NSString *const kAppiraterReminderRequestDate;
You could call to show the prompt regardless Appirater settings,
e.g., in case of some special event in your app.
*/
+ (void)tryToShowPrompt;
+ (BOOL)tryToShowPrompt;

/*!
Tells Appirater to show the prompt (a rating alert).
Expand Down
26 changes: 21 additions & 5 deletions Appirater.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ @interface Appirater ()
@property (nonatomic, copy) NSString *alertRateLaterTitle;
- (BOOL)connectedToNetwork;
+ (Appirater*)sharedInstance;
- (void)showPromptWithChecks:(BOOL)withChecks
- (BOOL)showPromptWithChecks:(BOOL)withChecks
displayRateLaterButton:(BOOL)displayRateLaterButton;
- (void)showRatingAlert:(BOOL)displayRateLaterButton;
- (void)showRatingAlert;
Expand Down Expand Up @@ -168,8 +168,22 @@ + (NSBundle *)bundle
NSURL *appiraterBundleURL = [[NSBundle mainBundle] URLForResource:@"Appirater" withExtension:@"bundle"];

if (appiraterBundleURL) {
NSBundle *myLanguageResourcesBundle = nil;
// Appirater.bundle will likely only exist when used via CocoaPods
bundle = [NSBundle bundleWithURL:appiraterBundleURL];

for(NSString *language in [NSLocale preferredLanguages])
{
myLanguageResourcesBundle = [NSBundle bundleWithPath:[bundle pathForResource:language ofType:@"lproj"]];
if(myLanguageResourcesBundle)
break;
}

if( myLanguageResourcesBundle == nil )
{
myLanguageResourcesBundle = bundle;
}
bundle = myLanguageResourcesBundle;
} else {
bundle = [NSBundle mainBundle];
}
Expand Down Expand Up @@ -518,8 +532,8 @@ + (void)showPrompt {
}
#pragma GCC diagnostic pop

+ (void)tryToShowPrompt {
[[Appirater sharedInstance] showPromptWithChecks:true
+ (BOOL)tryToShowPrompt {
return [[Appirater sharedInstance] showPromptWithChecks:true
displayRateLaterButton:true];
}

Expand All @@ -528,17 +542,19 @@ + (void)forceShowPrompt:(BOOL)displayRateLaterButton {
displayRateLaterButton:displayRateLaterButton];
}

- (void)showPromptWithChecks:(BOOL)withChecks
- (BOOL)showPromptWithChecks:(BOOL)withChecks
displayRateLaterButton:(BOOL)displayRateLaterButton {
bool showPrompt = true;
if (withChecks) {
showPrompt = ([self connectedToNetwork]
&& ![self userHasDeclinedToRate]
&& ![self userHasRatedCurrentVersion]);
&& ![self userHasRatedCurrentVersion]
&& [self ratingConditionsHaveBeenMet]);
}
if (showPrompt) {
[self showRatingAlert:displayRateLaterButton];
}
return showPrompt;
}

+ (id)getRootViewController {
Expand Down