Add support for App Extensions

- Added simple detection method to check wether the SDK runs in an extension
- BITCrashManager will send crash reports without UI (UIAlertViews aren't allowed in extensions anyway)
- Don't start BITUpdateManager, BITStoreUpdateManager, BITFeedbackManager and BITAuthenticator in app extensions
This commit is contained in:
Andreas Linde 2014-09-24 17:06:22 +02:00
parent 03767a63ef
commit 2040206101
4 changed files with 22 additions and 2 deletions

View File

@ -919,7 +919,10 @@ static PLCrashReporterCallbacks plCrashCallbacks = {
* - Send pending approved crash reports
*/
- (void)invokeDelayedProcessing {
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) return;
if (!bit_isRunningInAppExtension() &&
[[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) {
return;
}
BITHockeyLog(@"INFO: Start delayed CrashManager processing");
@ -945,7 +948,7 @@ static PLCrashReporterCallbacks plCrashCallbacks = {
_lastCrashFilename = [notApprovedReportFilename lastPathComponent];
}
if (!BITHockeyBundle()) {
if (!BITHockeyBundle() || bit_isRunningInAppExtension()) {
[self sendNextCrashReport];
} else if (_crashManagerStatus != BITCrashManagerStatusAutoSend && notApprovedReportFilename) {

View File

@ -48,6 +48,7 @@ NSString *bit_UUID(void);
NSString *bit_appAnonID(void);
BOOL bit_isPreiOS7Environment(void);
BOOL bit_isPreiOS8Environment(void);
BOOL bit_isRunningInAppExtension(void);
NSString *bit_validAppIconStringFromIcons(NSBundle *resourceBundle, NSArray *icons);
NSString *bit_validAppIconFilename(NSBundle *bundle, NSBundle *resourceBundle);

View File

@ -260,6 +260,17 @@ BOOL bit_isPreiOS8Environment(void) {
return isPreiOS8Environment;
}
BOOL bit_isRunningInAppExtension(void) {
static BOOL isRunningInAppExtension = NO;
static dispatch_once_t checkAppExtension;
dispatch_once(&checkAppExtension, ^{
isRunningInAppExtension = [[[NSBundle mainBundle] executablePath] containsString:@".appex/"];
});
return isRunningInAppExtension;
}
/**
Find a valid app icon filename that points to a proper app icon image

View File

@ -242,6 +242,11 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
}
#endif /* HOCKEYSDK_FEATURE_CRASH_REPORTER */
// App Extensions can only use BITCrashManager, so ignore all others automatically
if (bit_isRunningInAppExtension()) {
return;
}
#if HOCKEYSDK_FEATURE_STORE_UPDATES
// start StoreUpdateManager
if ([self isStoreUpdateManagerEnabled]) {