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 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 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 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. is reopened.
This may be useful to some customers looking to do conditional instrumentation at the close of a session. @return Returns whether the session was resumed or a new session was started. If the user has opted
It is perfectly reasonable to ignore the return value. out of analytics then the return from this method is undefined.
@result YES if the sesion was resumed NO if it wasn't (suggesting a new session was created instead).*/ */
- (BOOL)resume; - (BOOL)resume;
/*! /*!

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

@ -22,7 +22,7 @@
#pragma mark Constants #pragma mark Constants
#define PREFERENCES_KEY @"_localytics_install_id" // The randomly generated ID for each install of the app #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 LOCALYTICS_DIR @".localytics" // The directory in which the Localytics database is stored
#define IFT_ETHER 0x6 // Ethernet CSMACD #define IFT_ETHER 0x6 // Ethernet CSMACD
#define PATH_TO_APT @"/private/var/lib/apt/" #define PATH_TO_APT @"/private/var/lib/apt/"
@ -200,48 +200,54 @@ CLLocationCoordinate2D lastDeviceLocation = {0};
}); });
} }
- (BOOL)resume { - (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) { // Do nothing if session is already open
[self logMessage:@"Can't resume session because user is opted out."]; if(self.isSessionOpen == YES)
resumed = NO; return YES;
return;
}
// conditions for resuming previous session BOOL ret = NO;
if(self.sessionHasBeenOpen && // conditions for resuming previous session
(!self.sessionCloseTime || if(self.sessionHasBeenOpen &&
[self.sessionCloseTime timeIntervalSinceNow]*-1 <= self.backgroundSessionTimeout)) { (!self.sessionCloseTime ||
// Note that we allow the session to be resumed even if the database size exceeds the [self.sessionCloseTime timeIntervalSinceNow]*-1 <= self.backgroundSessionTimeout)) {
// maximum. This is because we don't want to create incomplete sessions. If the DB was large // Note that we allow the session to be resumed even if the database size exceeds the
// enough that the previous session could not be opened, there will be nothing to resume. But // maximum. This is because we don't want to create incomplete sessions. If the DB was large
// if this session caused it to go over it is better to let it complete and stop the next one // enough that the previous session could not be opened, there will be nothing to resume. But
// from being created. // if this session caused it to go over it is better to let it complete and stop the next one
[self logMessage:@"Resume called - Resuming previous session."]; // from being created.
[self reopenPreviousSession]; 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 {
} else { ret = NO;
// otherwise open new session and upload dispatch_async(_queue, ^{
[self logMessage:@"Resume called - Opening a new session."]; @try {
[self ll_open]; 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;
self.sessionCloseTime = nil; return ret;
} @catch (NSException *e) {}
});
return resumed;
} }
- (void)close { - (void)close {
@ -1120,10 +1126,11 @@ CLLocationCoordinate2D lastDeviceLocation = {0};
*/ */
- (NSString *)advertisingIdentifier { - (NSString *)advertisingIdentifier {
NSString *adId = nil; NSString *adId = nil;
SEL adidSelector = NSSelectorFromString(@"identifierForAdvertising"); Class advertisingClass = NSClassFromString(@"ASIdentifierManager");
if ([[UIDevice currentDevice] respondsToSelector:adidSelector]) { if (advertisingClass) {
adId = [[[UIDevice currentDevice] performSelector:adidSelector] performSelector:NSSelectorFromString(@"UUIDString")]; SEL adidSelector = NSSelectorFromString(@"advertisingIdentifier");
} adId = [[[advertisingClass performSelector:NSSelectorFromString(@"sharedManager")] performSelector:adidSelector] performSelector:NSSelectorFromString(@"UUIDString")];
}
return adId; 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