forked from organicmaps/organicmaps
[ios] Added ability to pass feature parameters in AppInfo
This commit is contained in:
parent
1e00b4fec3
commit
d0bbe982c6
3 changed files with 33 additions and 2 deletions
|
@ -631,7 +631,13 @@ const long long LITE_IDL = 431183278L;
|
|||
AppInfo * info = [AppInfo sharedInfo];
|
||||
NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSDate * lastShowDate = [userDefaults objectForKey:@"BANNER_SHOW_TIME"];
|
||||
BOOL showTime = lastShowDate ? [[NSDate date] timeIntervalSinceDate:lastShowDate] > (1 * 60 * 60) : YES;
|
||||
NSString * periodString = [info featureValue:AppFeatureInterstitialAd forKey:@"period"];
|
||||
NSTimeInterval period;
|
||||
if ([periodString length])
|
||||
period = [periodString doubleValue];
|
||||
else
|
||||
period = 3600;
|
||||
BOOL showTime = lastShowDate ? [[NSDate date] timeIntervalSinceDate:lastShowDate] > period : YES;
|
||||
if ([info featureAvailable:AppFeatureInterstitialAd] && info.launchCount >= 3 && showTime)
|
||||
{
|
||||
if (self.interstitialAd.ready)
|
||||
|
|
|
@ -10,6 +10,8 @@ extern NSString * const AppFeatureBannerAd;
|
|||
+ (instancetype)sharedInfo;
|
||||
|
||||
- (BOOL)featureAvailable:(NSString *)featureName;
|
||||
- (NSString *)featureValue:(NSString *)featureName forKey:(NSString *)key;
|
||||
|
||||
- (NSString *)snapshot;
|
||||
|
||||
@property (nonatomic, readonly) NSString * countryCode;
|
||||
|
|
|
@ -88,7 +88,8 @@ NSString * const AppFeatureBannerAd = @"BannerAd";
|
|||
NSString * value = self.features[featureName];
|
||||
if (value)
|
||||
{
|
||||
if ([value rangeOfString:self.countryCode options:NSCaseInsensitiveSearch].location != NSNotFound)
|
||||
NSString * countryCode = [@"@" stringByAppendingString:self.countryCode];
|
||||
if ([value rangeOfString:countryCode options:NSCaseInsensitiveSearch].location != NSNotFound)
|
||||
return YES;
|
||||
if ([value rangeOfString:@"*"].location != NSNotFound)
|
||||
return YES;
|
||||
|
@ -96,6 +97,28 @@ NSString * const AppFeatureBannerAd = @"BannerAd";
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)featureValue:(NSString *)featureName forKey:(NSString *)key
|
||||
{
|
||||
NSString * value = self.features[featureName];
|
||||
NSArray * components = [value componentsSeparatedByString:@"@"];
|
||||
for (NSString * countryComponent in components)
|
||||
{
|
||||
BOOL countryExist = [countryComponent rangeOfString:self.countryCode options:NSCaseInsensitiveSearch].location != NSNotFound;
|
||||
BOOL allExist = [countryComponent rangeOfString:@"*" options:NSCaseInsensitiveSearch].location != NSNotFound;
|
||||
if (countryExist || allExist)
|
||||
{
|
||||
NSArray * parameters = [countryComponent componentsSeparatedByString:@"#"];
|
||||
for (NSString * parameter in parameters) {
|
||||
NSRange range = [parameter rangeOfString:key options:NSCaseInsensitiveSearch];
|
||||
NSInteger startIndex = range.location + range.length + 1;
|
||||
if (range.location != NSNotFound && [parameter length] > startIndex)
|
||||
return [parameter substringFromIndex:startIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)snapshot
|
||||
{
|
||||
return [NSString stringWithFormat:@"MapsWithMe ver. %@, %@ (iOS %@) %@", self.bundleVersion, self.deviceInfo, self.firmwareVersion, self.countryCode];
|
||||
|
|
Loading…
Add table
Reference in a new issue