diff --git a/Airbrake/notifier/ABNotifier.h b/Airbrake/notifier/ABNotifier.h index 17fdfdb..30af48f 100644 --- a/Airbrake/notifier/ABNotifier.h +++ b/Airbrake/notifier/ABNotifier.h @@ -129,6 +129,32 @@ extern NSString * const ABNotifierDidPostNoticesNotification; installSignalHandler:(BOOL)signal displayUserPrompt:(BOOL)display; ++ (void)startNotifierWithAPIKey:(NSString *)key + projectID:(NSString *)projectId + hostName:(NSString *)hostName + environmentName:(NSString *)name + useSSL:(BOOL)useSSL + delegate:(id)delegate; ++ (void)startNotifierWithAPIKey:(NSString *)key + projectID:(NSString *)projectId + hostName:(NSString *)hostName + environmentName:(NSString *)name + userName:(NSString *)username + useSSL:(BOOL)useSSL + delegate:(id)delegate + installExceptionHandler:(BOOL)exception + installSignalHandler:(BOOL)signal; ++ (void)startNotifierWithAPIKey:(NSString *)key + projectID:(NSString *)projectId + hostName:(NSString *)hostName + environmentName:(NSString *)name + userName:(NSString *)username + useSSL:(BOOL)useSSL + delegate:(id)delegate + installExceptionHandler:(BOOL)exception + installSignalHandler:(BOOL)signal + displayUserPrompt:(BOOL)display; + /* Methods to expose some variables used by the notifier. diff --git a/Airbrake/notifier/ABNotifier.m b/Airbrake/notifier/ABNotifier.m index 241609f..76af931 100644 --- a/Airbrake/notifier/ABNotifier.m +++ b/Airbrake/notifier/ABNotifier.m @@ -34,6 +34,9 @@ of this software and associated documentation files (the "Software"), to deal static NSMutableDictionary *__userData; static NSString * __APIKey = nil; static NSString * __ABProjectID = nil; +//__hostName will be used to format the URL to post the crash report. +//By default the hostName is airbrake.io and url is https://api.airbrake.io/api/v3/projects/%d/... +static NSString * __hostName = nil; static BOOL __useSSL = NO; static BOOL __displayPrompt = YES; static NSString *__userName = @"Anonymous"; @@ -105,21 +108,45 @@ + (void)startNotifierWithAPIKey:(NSString *)key projectID:(NSString *)projectId [self startNotifierWithAPIKey:key projectID:projectId environmentName:name userName:__userName useSSL:useSSL delegate:delegate installExceptionHandler:exception installSignalHandler:signal displayUserPrompt:YES]; } ++ (void)startNotifierWithAPIKey:(NSString *)key projectID:(NSString *)projectId environmentName:(NSString *)name userName:(NSString *)username useSSL:(BOOL)useSSL delegate:(id)delegate { + [self startNotifierWithAPIKey:key projectID:projectId environmentName:name userName:username useSSL:useSSL delegate:delegate + installExceptionHandler:YES + installSignalHandler:YES + displayUserPrompt:YES]; +} + ++ (void)startNotifierWithAPIKey:(NSString *)key projectID:(NSString *)projectId environmentName:(NSString *)name userName:(NSString *)username useSSL:(BOOL)useSSL delegate:(id)delegate installExceptionHandler:(BOOL)exception installSignalHandler:(BOOL)signal displayUserPrompt:(BOOL)display { + [self startNotifierWithAPIKey:key projectID:projectId hostName:nil environmentName:name userName:username useSSL:useSSL delegate:delegate + installExceptionHandler:exception + installSignalHandler:signal + displayUserPrompt:display]; +} + ++ (void)startNotifierWithAPIKey:(NSString *)key projectID:(NSString *)projectId hostName:(NSString *)hostName environmentName:(NSString *)name useSSL:(BOOL)useSSL delegate:(id)delegate { + [self startNotifierWithAPIKey:key projectID:projectId hostName:hostName environmentName:name userName:__userName useSSL:useSSL delegate:delegate + installExceptionHandler:YES + installSignalHandler:YES + displayUserPrompt:YES]; +} + + (void)startNotifierWithAPIKey:(NSString *)key projectID:(NSString *)projectId + hostName:(NSString *)hostName environmentName:(NSString *)name userName:(NSString *)username useSSL:(BOOL)useSSL - delegate:(id)delegate { - [self startNotifierWithAPIKey:key projectID:projectId environmentName:name userName:username useSSL:useSSL delegate:delegate - installExceptionHandler:YES - installSignalHandler:YES + delegate:(id)delegate + installExceptionHandler:(BOOL)exception + installSignalHandler:(BOOL)signal { + [self startNotifierWithAPIKey:key projectID:projectId hostName:hostName environmentName:name userName:username useSSL:useSSL delegate:delegate + installExceptionHandler:exception + installSignalHandler:signal displayUserPrompt:YES]; } - + (void)startNotifierWithAPIKey:(NSString *)key projectID:(NSString *)projectId + hostName:(NSString *)hostName environmentName:(NSString *)name userName:(NSString *)username useSSL:(BOOL)useSSL @@ -131,7 +158,9 @@ + (void)startNotifierWithAPIKey:(NSString *)key static BOOL token = YES; if (token) { // store username - __userName = username; + if (username && username.length > 0) { + __userName = username; + } // change token5 token = NO; @@ -141,6 +170,12 @@ + (void)startNotifierWithAPIKey:(NSString *)key [NSDictionary dictionaryWithObject:@"NO" forKey:ABNotifierAlwaysSendKey]]; // capture vars + if (hostName && hostName.length > 0) { + __hostName = hostName; + } else { + __hostName = ABNotifierHostName; + } + __userData = [[NSMutableDictionary alloc] init]; __delegate = delegate; __useSSL = useSSL; @@ -511,8 +546,8 @@ + (void)postNoticeWithContentsOfFile:(NSString *)path { // create url //API V3 iOS report https://api.airbrake.io/api/v3/projects/%d/ios-reports?key=API_KEY NSString *URLString = [NSString stringWithFormat: - @"%@://api.airbrake.io/api/v3/projects/%@/ios-reports?key=%@", - (__useSSL ? @"https" : @"http"), + @"%@://api.%@/api/v3/projects/%@/ios-reports?key=%@", + (__useSSL ? @"https" : @"http"), __hostName, [self projectID], [self APIKey]]; NSData *jsonData; NSString *fileType = [path pathExtension]; @@ -522,8 +557,8 @@ + (void)postNoticeWithContentsOfFile:(NSString *)path { } else { //current V3 API https://api.airbrake.io/api/v3/projects/%d/notices?key=API_KEY URLString = [NSString stringWithFormat: - @"%@://api.airbrake.io/api/v3/projects/%@/notices?key=%@", - (__useSSL ? @"https" : @"http"), + @"%@://api.%@/api/v3/projects/%@/notices?key=%@", + (__useSSL ? @"https" : @"http"), __hostName, [self projectID], [self APIKey]]; // get ABNotice ABNotice *notice = [ABNotice noticeWithContentsOfFile:path]; diff --git a/Xcode/Airbrake Mac/AirbrakeMac-Info.plist b/Xcode/Airbrake Mac/AirbrakeMac-Info.plist index 1971458..9088b7a 100644 --- a/Xcode/Airbrake Mac/AirbrakeMac-Info.plist +++ b/Xcode/Airbrake Mac/AirbrakeMac-Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - com.guicocoa.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Xcode/Airbrake iOS/AirbrakeiOS-Info.plist b/Xcode/Airbrake iOS/AirbrakeiOS-Info.plist index e8172d7..8b76d40 100644 --- a/Xcode/Airbrake iOS/AirbrakeiOS-Info.plist +++ b/Xcode/Airbrake iOS/AirbrakeiOS-Info.plist @@ -11,7 +11,7 @@ CFBundleIconFile CFBundleIdentifier - com.guicocoa.airbrakeios + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Xcode/Airbrake.xcodeproj/project.pbxproj b/Xcode/Airbrake.xcodeproj/project.pbxproj index 7dfbfb4..d74c5c5 100644 --- a/Xcode/Airbrake.xcodeproj/project.pbxproj +++ b/Xcode/Airbrake.xcodeproj/project.pbxproj @@ -276,11 +276,11 @@ 3B2E0B1A137A11B1009B558C /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0730; ORGANIZATIONNAME = ""; TargetAttributes = { 3B2E0B65137A11F8009B558C = { - DevelopmentTeam = 58JWY6KSB8; + DevelopmentTeam = U49DNE22RB; }; }; }; @@ -453,6 +453,7 @@ LD_RUNPATH_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Airbrake\\ Mac"; MACOSX_DEPLOYMENT_TARGET = 10.6; + PRODUCT_BUNDLE_IDENTIFIER = "com.guicocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = AirbrakeMac; SDKROOT = macosx; WRAPPER_EXTENSION = app; @@ -478,6 +479,7 @@ LD_RUNPATH_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Airbrake\\ Mac"; MACOSX_DEPLOYMENT_TARGET = 10.6; + PRODUCT_BUNDLE_IDENTIFIER = "com.guicocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = AirbrakeMac; SDKROOT = macosx; WRAPPER_EXTENSION = app; @@ -495,6 +497,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -546,6 +549,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Airbrake\\ iOS", @@ -555,6 +559,7 @@ GCC_PREFIX_HEADER = "Airbrake iOS/AirbrakeiOS-Prefix.pch"; INFOPLIST_FILE = "Airbrake iOS/AirbrakeiOS-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_BUNDLE_IDENTIFIER = com.guicocoa.airbrakeios; PRODUCT_NAME = AirbrakeiOS; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -572,6 +577,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Airbrake\\ iOS", @@ -580,6 +586,7 @@ GCC_PREFIX_HEADER = "Airbrake iOS/AirbrakeiOS-Prefix.pch"; INFOPLIST_FILE = "Airbrake iOS/AirbrakeiOS-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_BUNDLE_IDENTIFIER = com.guicocoa.airbrakeios; PRODUCT_NAME = AirbrakeiOS; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos;