Skip to content

Commit

Permalink
Merge pull request #74 from airbrake/pr/25
Browse files Browse the repository at this point in the history
Made hostName available as a parameter for startNotifier
  • Loading branch information
jocelynlih authored Aug 22, 2016
2 parents 4f386c2 + db01bd7 commit 0421685
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 14 deletions.
26 changes: 26 additions & 0 deletions Airbrake/notifier/ABNotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ABNotifierDelegate>)delegate;
+ (void)startNotifierWithAPIKey:(NSString *)key
projectID:(NSString *)projectId
hostName:(NSString *)hostName
environmentName:(NSString *)name
userName:(NSString *)username
useSSL:(BOOL)useSSL
delegate:(id<ABNotifierDelegate>)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<ABNotifierDelegate>)delegate
installExceptionHandler:(BOOL)exception
installSignalHandler:(BOOL)signal
displayUserPrompt:(BOOL)display;

/*
Methods to expose some variables used by the notifier.
Expand Down
55 changes: 45 additions & 10 deletions Airbrake/notifier/ABNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<ABNotifierDelegate>)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<ABNotifierDelegate>)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<ABNotifierDelegate>)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<ABNotifierDelegate>)delegate {
[self startNotifierWithAPIKey:key projectID:projectId environmentName:name userName:username useSSL:useSSL delegate:delegate
installExceptionHandler:YES
installSignalHandler:YES
delegate:(id<ABNotifierDelegate>)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
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion Xcode/Airbrake Mac/AirbrakeMac-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.guicocoa.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
2 changes: 1 addition & 1 deletion Xcode/Airbrake iOS/AirbrakeiOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.guicocoa.airbrakeios</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
11 changes: 9 additions & 2 deletions Xcode/Airbrake.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,11 @@
3B2E0B1A137A11B1009B558C /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0630;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "";
TargetAttributes = {
3B2E0B65137A11F8009B558C = {
DevelopmentTeam = 58JWY6KSB8;
DevelopmentTeam = U49DNE22RB;
};
};
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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",
Expand All @@ -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;
Expand All @@ -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",
Expand All @@ -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;
Expand Down

0 comments on commit 0421685

Please sign in to comment.