Herbie999 Herbie999 - 3 months ago 19
iOS Question

How do I edit title and messages in irate for ios?

I have added the .h .m and .bundle files for irate. I set the preview mode to YES so the Alert View pops up right when my app launches on my phone (I'm testing). It doesn't show the Alert View at all if I don't set the preview mode to YES.
So now it pops up the rating Alert View. In the .m file I tried editing the title, message and button text in the string and it still shows the original title, message and button text even though it does not exist in the .m because I have completely changed it. Does anyone know how to edit this text so that it will edit the text that appears on the Alert View. The code is below as it came from my download of irate. If I change the text in the strings it doesn't change when I test it still shows what is there right now. Going around in circles here and I'm guessing I'm missing something simple, any help would be awesome!

- (NSString *)messageTitle
{
return [_messageTitle ?: [self localizedStringForKey:iRateMessageTitleKey withDefault:@"Rate %@"] stringByReplacingOccurrencesOfString:@"%@" withString:self.applicationName];
}

- (NSString *)message
{
NSString *message = _message;
if (!message)
{
message = (self.appStoreGenreID == iRateAppStoreGameGenreID)? [self localizedStringForKey:iRateGameMessageKey withDefault:@"If you enjoy playing %@, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!"]: [self localizedStringForKey:iRateAppMessageKey withDefault:@"If you enjoy using %@, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!"];
}
return [message stringByReplacingOccurrencesOfString:@"%@" withString:self.applicationName];
}

- (NSString *)cancelButtonLabel
{
return _cancelButtonLabel ?: [self localizedStringForKey:iRateCancelButtonKey withDefault:@"No, Thanks"];
}

- (NSString *)rateButtonLabel
{
return _rateButtonLabel ?: [self localizedStringForKey:iRateRateButtonKey withDefault:@"Rate It Now"];
}

- (NSString *)remindButtonLabel
{
return _remindButtonLabel ?: [self localizedStringForKey:iRateRemindButtonKey withDefault:@"Remind Me Later"];
}

Answer Source

As suggested in the iRate documentation on GitHub, there are two ways you can override those strings:

1) you can override the default strings in your app delegate initialize class method:

+ (void)initialize
{
    //overriding the default iRate strings
    [iRate sharedInstance].messageTitle = NSLocalizedString(@"Rate MyApp", @"iRate message title");
    [iRate sharedInstance].message = NSLocalizedString(@"If you like MyApp, please take the time, etc", @"iRate message");
    [iRate sharedInstance].cancelButtonLabel = NSLocalizedString(@"No, Thanks", @"iRate decline button");
    [iRate sharedInstance].remindButtonLabel = NSLocalizedString(@"Remind Me Later", @"iRate remind button");
    [iRate sharedInstance].rateButtonLabel = NSLocalizedString(@"Rate It Now", @"iRate accept button");
}

2) The recommended way is that you can also create your own Localizable.strings file and add those strings found in iRate.h:

//localisation string keys
static NSString *const iRateMessageTitleKey = @"iRateMessageTitle";
static NSString *const iRateAppMessageKey = @"iRateAppMessage";
static NSString *const iRateGameMessageKey = @"iRateGameMessage";
static NSString *const iRateCancelButtonKey = @"iRateCancelButton";
static NSString *const iRateRemindButtonKey = @"iRateRemindButton";
static NSString *const iRateRateButtonKey = @"iRateRateButton";

For example, inside the Localizable.strings file:

"iRateMessageTitle" = "My own rating title";
"iRateAppMessage" = "My own rating message";