forked from organicmaps/organicmaps
[ios] AppInfo properties become readonly
Added LaunchCount property
This commit is contained in:
parent
1335fd1d7e
commit
ddab321579
2 changed files with 43 additions and 9 deletions
|
@ -2,6 +2,9 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "Reachability.h"
|
||||
|
||||
extern NSString * const AppFeatureInterstitialAd;
|
||||
extern NSString * const AppFeatureBannerAd;
|
||||
|
||||
@interface AppInfo : NSObject
|
||||
|
||||
+ (instancetype)sharedInfo;
|
||||
|
@ -9,12 +12,13 @@
|
|||
- (BOOL)featureAvailable:(NSString *)featureName;
|
||||
- (NSString *)snapshot;
|
||||
|
||||
@property (nonatomic, strong) NSString * countryCode;
|
||||
@property (nonatomic, strong) NSString * bundleVersion;
|
||||
@property (nonatomic, strong) NSString * deviceInfo;
|
||||
@property (nonatomic, strong) NSString * firmwareVersion;
|
||||
@property (nonatomic, strong) NSString * uniqueId;
|
||||
@property (nonatomic, strong) NSString * advertisingId;
|
||||
@property (nonatomic, strong) Reachability * reachability;
|
||||
@property (nonatomic, strong, readonly) NSString * countryCode;
|
||||
@property (nonatomic, strong, readonly) NSString * bundleVersion;
|
||||
@property (nonatomic, strong, readonly) NSString * deviceInfo;
|
||||
@property (nonatomic, strong, readonly) NSString * firmwareVersion;
|
||||
@property (nonatomic, strong, readonly) NSString * uniqueId;
|
||||
@property (nonatomic, strong, readonly) NSString * advertisingId;
|
||||
@property (nonatomic, strong, readonly) Reachability * reachability;
|
||||
@property (nonatomic, readonly) NSInteger launchCount;
|
||||
|
||||
@end
|
||||
|
|
|
@ -6,11 +6,23 @@
|
|||
#import <AdSupport/ASIdentifierManager.h>
|
||||
#include "../../../platform/settings.hpp"
|
||||
|
||||
NSString * const AppFeatureInterstitialAd = @"InterstitialAd";
|
||||
NSString * const AppFeatureBannerAd = @"BannerAd";
|
||||
|
||||
@interface AppInfo ()
|
||||
|
||||
@property (nonatomic) NSDictionary * features;
|
||||
@property NSDictionary * featuresByDefault;
|
||||
|
||||
@property (nonatomic) NSInteger launchCount;
|
||||
@property (nonatomic, strong) NSString * countryCode;
|
||||
@property (nonatomic, strong) NSString * bundleVersion;
|
||||
@property (nonatomic, strong) NSString * deviceInfo;
|
||||
@property (nonatomic, strong) NSString * firmwareVersion;
|
||||
@property (nonatomic, strong) NSString * uniqueId;
|
||||
@property (nonatomic, strong) NSString * advertisingId;
|
||||
@property (nonatomic, strong) Reachability * reachability;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppInfo
|
||||
|
@ -19,6 +31,10 @@
|
|||
{
|
||||
self = [super init];
|
||||
|
||||
self.launchCount++;
|
||||
self.featuresByDefault = @{AppFeatureInterstitialAd : @YES,
|
||||
AppFeatureBannerAd : @NO};
|
||||
|
||||
[self update];
|
||||
|
||||
return self;
|
||||
|
@ -34,7 +50,8 @@
|
|||
featuresString = [featuresString stringByAppendingString:@";"];
|
||||
featuresString = [NSString stringWithFormat:@"%@%@:%@", featuresString, featureName, self.features[featureName]];
|
||||
}
|
||||
Settings::Set("AvailableFeatures", std::string([featuresString UTF8String]));
|
||||
if ([featuresString length])
|
||||
Settings::Set("AvailableFeatures", std::string([featuresString UTF8String]));
|
||||
}
|
||||
|
||||
- (void)update
|
||||
|
@ -46,7 +63,8 @@
|
|||
// if failed then subscribing for reachability updates
|
||||
__weak id weakSelf = self;
|
||||
self.reachability.reachableBlock = ^(Reachability * r){
|
||||
[weakSelf update];
|
||||
if ([r isReachable])
|
||||
[weakSelf update];
|
||||
};
|
||||
[self.reachability startNotifier];
|
||||
}
|
||||
|
@ -71,6 +89,18 @@
|
|||
|
||||
#pragma mark - Public properties
|
||||
|
||||
- (void)setLaunchCount:(NSInteger)launchCount
|
||||
{
|
||||
Settings::Set("LaunchCount", (int)launchCount);
|
||||
}
|
||||
|
||||
- (NSInteger)launchCount
|
||||
{
|
||||
int count = 0;
|
||||
Settings::Get("LaunchCount", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
- (NSString *)uniqueId
|
||||
{
|
||||
if (!_uniqueId)
|
||||
|
|
Loading…
Add table
Reference in a new issue