Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using HockeyAppSDK pod subspecs #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 64 additions & 31 deletions RNHockeyApp/RNHockeyApp/RNHockeyApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
static NSString *token = nil;
static NSString *appSecret = nil;

#if HOCKEYSDK_FEATURE_CRASH_REPORTER
@interface RNHockeyApp() <BITHockeyManagerDelegate, BITCrashManagerDelegate>
@end
#else
@interface RNHockeyApp() <BITHockeyManagerDelegate>
@end
#endif

@implementation RNHockeyApp

Expand All @@ -42,34 +47,15 @@ @implementation RNHockeyApp
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:token
delegate:self];
if (autoSend == YES) {
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
[[BITHockeyManager sharedHockeyManager].crashManager setCrashManagerStatus:BITCrashManagerStatusAutoSend];
#else
NSLog(@"CrashManager not included in HockeyApp SDK installation! \n");
#endif
}
switch (authType) {
case EmailSecret:
NSLog(@"react-native-hockeyapp: Email + Secret Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setAuthenticationSecret:appSecret];
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeHockeyAppEmail];
break;
case EmailPassword:
NSLog(@"react-native-hockeyapp: Email + Password Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeHockeyAppUser];
break;
case DeviceUUID:
NSLog(@"react-native-hockeyapp: Device UUID Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeDevice];
break;
case WebAuth:
NSLog(@"react-native-hockeyapp: Web Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeWebAuth];
break;
case Anonymous:
default:
NSLog(@"react-native-hockeyapp: Anonymous Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeAnonymous];
break;
}

[RNHockeyApp setupAuthenticator];
[[BITHockeyManager sharedHockeyManager] startManager];
[[BITHockeyManager sharedHockeyManager].authenticator authenticateInstallation];

[RNHockeyApp deleteMetadataFileIfExists];
});
Expand Down Expand Up @@ -99,40 +85,46 @@ @implementation RNHockeyApp
}
}

#if HOCKEYSDK_FEATURE_FEEDBACK
RCT_EXPORT_METHOD(feedback)
{
#if HOCKEYSDK_FEATURE_FEEDBACK
if (initialized == YES) {
[[BITHockeyManager sharedHockeyManager].feedbackManager showFeedbackListView];
} else {
NSLog(@"Not initialized! \n");
}
}
#else
RCT_EXPORT_METHOD(feedback)
{
NSLog(@"Feedback not included in HockeyApp SDK installation! \n");
}
#endif
}

RCT_EXPORT_METHOD(checkForUpdate)
{
#if HOCKEYSDK_FEATURE_UPDATES
if (initialized == YES) {
[[BITHockeyManager sharedHockeyManager].updateManager checkForUpdate];
} else {
NSLog(@"Not initialized! \n");
}
#else
NSLog(@"Updates not included in HockeyApp SDK installation! \n");
#endif
}

RCT_EXPORT_METHOD(generateTestCrash)
{
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
if (initialized == YES) {
[[BITHockeyManager sharedHockeyManager].crashManager generateTestCrash];
}
#else
NSLog(@"CrashManager not included in HockeyApp SDK installation! \n");
#endif
}

RCT_EXPORT_METHOD(trackEvent:(NSString *)eventName)
{
#if HOCKEYSDK_FEATURE_METRICS
if (initialized == YES) {
if ([eventName length] > 0) {
BITMetricsManager *metricsManager = [[BITHockeyManager sharedHockeyManager] metricsManager];
Expand All @@ -141,10 +133,14 @@ @implementation RNHockeyApp
NSLog(@"react-native-hockeyapp: An event name must be provided.");
}
}
#else
NSLog(@"Metrics not included in HockeyApp SDK installation! \n");
#endif
}

RCT_EXPORT_METHOD(trackEventWithOptionsAndMeasurements:(NSString *)eventName Options:(NSDictionary *)options Measurements:(NSDictionary *)measurements)
{
#if HOCKEYSDK_FEATURE_METRICS
if (initialized == YES) {
if ([eventName length] > 0) {
BITMetricsManager *metricsManager = [[BITHockeyManager sharedHockeyManager] metricsManager];
Expand All @@ -153,6 +149,42 @@ @implementation RNHockeyApp
NSLog(@"react-native-hockeyapp: An event name must be provided.");
}
}
#else
NSLog(@"Metrics not included in HockeyApp SDK installation! \n");
#endif
}

+ (void)setupAuthenticator
{
#if HOCKEYSDK_FEATURE_AUTHENTICATOR
switch (authType) {
case EmailSecret:
NSLog(@"react-native-hockeyapp: Email + Secret Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setAuthenticationSecret:appSecret];
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeHockeyAppEmail];
break;
case EmailPassword:
NSLog(@"react-native-hockeyapp: Email + Password Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeHockeyAppUser];
break;
case DeviceUUID:
NSLog(@"react-native-hockeyapp: Device UUID Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeDevice];
break;
case WebAuth:
NSLog(@"react-native-hockeyapp: Web Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeWebAuth];
break;
case Anonymous:
default:
NSLog(@"react-native-hockeyapp: Anonymous Auth set");
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeAnonymous];
break;
}
[[BITHockeyManager sharedHockeyManager].authenticator authenticateInstallation];
#else
NSLog(@"Authenticator not included in HockeyApp SDK installation! \n");
#endif
}

+ (void)deleteMetadataFileIfExists
Expand Down Expand Up @@ -187,11 +219,12 @@ + (NSString *)getMetadataFilePath
return [directoryPath stringByAppendingPathComponent:@"HockeyAppCrashMetadata.json"];
}

#if HOCKEYSDK_FEATURE_CRASH_REPORTER
- (NSString *)applicationLogForCrashManager:(BITCrashManager *)crashManager
{
NSString *filePath = [RNHockeyApp getMetadataFilePath];

return [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
}

#endif
@end
22 changes: 0 additions & 22 deletions ios/RNHockeyApp.h

This file was deleted.

173 changes: 0 additions & 173 deletions ios/RNHockeyApp.m

This file was deleted.