2
0

Localytics SDK update because of startup issue.

This commit is contained in:
Maarten Billemont 2012-09-21 19:42:18 +02:00
parent 850978cbe3
commit b1f0f70849
7 changed files with 56 additions and 49 deletions

0
Localytics/LocalyticsDatabase.h Normal file → Executable file
View File

0
Localytics/LocalyticsDatabase.m Normal file → Executable file
View File

8
Localytics/LocalyticsSession.h Normal file → Executable file
View File

@ -154,10 +154,10 @@
closed and the time of closing is recorded. When the app returns to the foreground, the session
is resumed. If the time since closing is greater than BACKGROUND_SESSION_TIMEOUT, (15 seconds
by default) a new session is created, and uploading is triggered. Otherwise, the previous session
is reopened. It is possible to use the return value to determine whether or not a session was resumed.
This may be useful to some customers looking to do conditional instrumentation at the close of a session.
It is perfectly reasonable to ignore the return value.
@result YES if the sesion was resumed NO if it wasn't (suggesting a new session was created instead).*/
is reopened.
@return Returns whether the session was resumed or a new session was started. If the user has opted
out of analytics then the return from this method is undefined.
*/
- (BOOL)resume;
/*!

53
Localytics/LocalyticsSession.m Normal file → Executable file
View File

@ -22,7 +22,7 @@
#pragma mark Constants
#define PREFERENCES_KEY @"_localytics_install_id" // The randomly generated ID for each install of the app
#define CLIENT_VERSION @"iOS_2.12" // The version of this library
#define CLIENT_VERSION @"iOS_2.14" // The version of this library
#define LOCALYTICS_DIR @".localytics" // The directory in which the Localytics database is stored
#define IFT_ETHER 0x6 // Ethernet CSMACD
#define PATH_TO_APT @"/private/var/lib/apt/"
@ -200,24 +200,14 @@ CLLocationCoordinate2D lastDeviceLocation = {0};
});
}
- (BOOL)resume {
__block BOOL resumed = NO;
dispatch_sync(_queue,^{
@try {
// Do nothing if session is already open
if(self.isSessionOpen == YES) {
resumed = YES;
return;
}
if([self ll_isOptedIn] == false) {
[self logMessage:@"Can't resume session because user is opted out."];
resumed = NO;
return;
}
if(self.isSessionOpen == YES)
return YES;
BOOL ret = NO;
// conditions for resuming previous session
if(self.sessionHasBeenOpen &&
(!self.sessionCloseTime ||
@ -227,21 +217,37 @@ CLLocationCoordinate2D lastDeviceLocation = {0};
// enough that the previous session could not be opened, there will be nothing to resume. But
// if this session caused it to go over it is better to let it complete and stop the next one
// from being created.
ret = YES;
dispatch_async(_queue, ^{
@try {
if([self ll_isOptedIn] == false) {
[self logMessage:@"Can't resume session because user is opted out."];
} else {
[self logMessage:@"Resume called - Resuming previous session."];
[self reopenPreviousSession];
}
}
@catch (NSException * e) {}
});
resumed = YES;
} else {
ret = NO;
dispatch_async(_queue, ^{
@try {
if([self ll_isOptedIn] == false) {
[self logMessage:@"Can't resume session because user is opted out."];
} else {
// otherwise open new session and upload
[self logMessage:@"Resume called - Opening a new session."];
[self ll_open];
}
}
@catch (NSException * e) {}
});
resumed = NO;
}
self.sessionCloseTime = nil;
} @catch (NSException *e) {}
});
return resumed;
return ret;
}
- (void)close {
@ -1120,9 +1126,10 @@ CLLocationCoordinate2D lastDeviceLocation = {0};
*/
- (NSString *)advertisingIdentifier {
NSString *adId = nil;
SEL adidSelector = NSSelectorFromString(@"identifierForAdvertising");
if ([[UIDevice currentDevice] respondsToSelector:adidSelector]) {
adId = [[[UIDevice currentDevice] performSelector:adidSelector] performSelector:NSSelectorFromString(@"UUIDString")];
Class advertisingClass = NSClassFromString(@"ASIdentifierManager");
if (advertisingClass) {
SEL adidSelector = NSSelectorFromString(@"advertisingIdentifier");
adId = [[[advertisingClass performSelector:NSSelectorFromString(@"sharedManager")] performSelector:adidSelector] performSelector:NSSelectorFromString(@"UUIDString")];
}
return adId;
}

0
Localytics/LocalyticsUploader.h Normal file → Executable file
View File

0
Localytics/LocalyticsUploader.m Normal file → Executable file
View File

0
Localytics/WebserviceConstants.h Normal file → Executable file
View File