Skip to content

Commit

Permalink
Fix Countly initialization error.
Browse files Browse the repository at this point in the history
Countly recently updated how the framework is initializated and it’s not backward compatible.

I added a condition which determines if the project using the old or new version and initializes Countly properely.
  • Loading branch information
Gergő Németh committed Oct 5, 2016
1 parent aa29479 commit 739ebf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions ARAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ + (void)setupWithAnalytics:(NSDictionary *)analyticsDictionary

if (analyticsDictionary[ARCountlyAppKey]) {
// ARCountlyHost is nil if you want the cloud host.
// If the host URL is not nil the it should be provided without the slash at the end.
[self setupCountlyWithAppKey:analyticsDictionary[ARCountlyAppKey] andHost:analyticsDictionary[ARCountlyHost]];
}

Expand Down
21 changes: 17 additions & 4 deletions Providers/CountlyProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@ @implementation CountlyProvider
- (instancetype)initWithAppKey:(NSString *)appKey andHost:(NSString *)host {
#ifdef AR_COUNTLY_EXISTS
NSAssert([Countly class], @"Countly is not included");
if (host) {
[[Countly sharedInstance] start:appKey withHost:host];
} else {
[[Countly sharedInstance] startOnCloudWithAppKey:appKey];

// since v16.0
if ([[Countly sharedInstance] respondsToSelector:@selector(startWithConfig:)]) {
CountlyConfig *config = [CountlyConfig new];
config.appKey = appKey;
if (host) {
config.host = host;
}
[[Countly sharedInstance] performSelector:@selector(startWithConfig:) withObject:config];
}
// before v16.0
else if ([[Countly sharedInstance] respondsToSelector:@selector(start:withHost:)]) {
if (host) {
[[Countly sharedInstance] performSelector:@selector(start:withHost:) withObject:appKey withObject:host];
} else {
[[Countly sharedInstance] performSelector:@selector(startOnCloudWithAppKey:) withObject:appKey];
}
}
#endif

Expand Down

0 comments on commit 739ebf0

Please sign in to comment.