From 2884bdf354c231419dd90d29e9d0d9037fdc57a2 Mon Sep 17 00:00:00 2001 From: Thomas Dohmke Date: Sat, 3 Dec 2011 17:57:16 +0100 Subject: [PATCH] Moved public API from BWHockeyManager to CNSHockeyManager. Fixed name of isShowingDirectInstallOption. --- Classes/BWHockeyManager.h | 20 +++--- Classes/BWHockeyManager.m | 2 +- Classes/CNSHockeyManager.h | 105 ++++++++++++++++++++++++++++++- Classes/CNSHockeyManager.m | 126 +++++++++++++++++++++++++++++++++++++ 4 files changed, 243 insertions(+), 10 deletions(-) diff --git a/Classes/BWHockeyManager.h b/Classes/BWHockeyManager.h index 41c3f56cbe..4a45b20245 100644 --- a/Classes/BWHockeyManager.h +++ b/Classes/BWHockeyManager.h @@ -111,13 +111,7 @@ typedef enum { /////////////////////////////////////////////////////////////////////////////////////////////////// -// settings - -// if YES, the API will return an existing JMC config -// if NO, the API will return only version information -@property (nonatomic, assign) BOOL checkForTracker; - -@property (nonatomic, retain, readonly) NSDictionary *trackerConfig; +// Setting Properties // if YES, states will be logged using NSLog. Only enable this for debugging! // if NO, nothing will be logged. (default) @@ -157,7 +151,7 @@ typedef enum { // if YES, the alert notifying about an new update also shows a button to install the update directly // if NO, the alert notifying about an new update only shows ignore and show update button -@property (nonatomic, assign, getter=ishowingDirectInstallOption) BOOL showDirectInstallOption; +@property (nonatomic, assign, getter=isShowingDirectInstallOption) BOOL showDirectInstallOption; // if YES, each app version needs to be authorized by the server to run on this device // if NO, each app version does not need to be authorized (default) @@ -172,7 +166,17 @@ typedef enum { @property (nonatomic, assign) HockeyUpdateSetting updateSetting; /////////////////////////////////////////////////////////////////////////////////////////////////// +// Private Properties +// if YES, the API will return an existing JMC config +// if NO, the API will return only version information +@property (nonatomic, assign) BOOL checkForTracker; + +// Contains the tracker config if received from server +@property (nonatomic, retain, readonly) NSDictionary *trackerConfig; + +// if YES the app is installed from the app store +// if NO the app is installed via ad-hoc or enterprise distribution @property (nonatomic, readonly) BOOL isAppStoreEnvironment; // is an update available? diff --git a/Classes/BWHockeyManager.m b/Classes/BWHockeyManager.m index fb4aca601d..44c7e99abb 100644 --- a/Classes/BWHockeyManager.m +++ b/Classes/BWHockeyManager.m @@ -537,7 +537,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain"; otherButtonTitles:BWHockeyLocalize(@"HockeyShowUpdate"), nil ] autorelease]; BW_IF_IOS4_OR_GREATER( - if (self.ishowingDirectInstallOption) { + if (self.isShowingDirectInstallOption) { [alertView addButtonWithTitle:BWHockeyLocalize(@"HockeyInstallUpdate")]; } ) diff --git a/Classes/CNSHockeyManager.h b/Classes/CNSHockeyManager.h index 5ad66942de..6f8699748f 100644 --- a/Classes/CNSHockeyManager.h +++ b/Classes/CNSHockeyManager.h @@ -19,7 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -@class BWHockeyManager; +#import "BWHockeyManager.h" + +#pragma mark - Delegate @protocol CNSHockeyManagerDelegate @@ -86,6 +88,8 @@ NSString *appIdentifier; } +#pragma mark - Public Properties + // Custom language style; set to a string which will be appended to // to the localization file name; the Hockey SDK includes an alternative // file, to use this, set to @"Alternate" @@ -93,6 +97,11 @@ // Default: nil @property (nonatomic, retain) NSString *languageStyle; +// Enable debug logging; ONLY ENABLE THIS FOR DEBUGGING! +// +// Default: NO +@property (nonatomic, assign, getter=isLoggingEnabled) BOOL loggingEnabled; + // Show button "Always" in crash alert; this will cause the dialog not to // show the alert description text landscape mode! (default) // @@ -118,6 +127,72 @@ // Default: NO @property (nonatomic, assign, getter=isAutoSubmitDeviceUDID) BOOL autoSubmitDeviceUDID; +// Send user data to HockeyApp when checking for a new version; works only +// for beta apps and should not be activated for live apps. User data includes +// the device type, OS version, app version and device UDID. +// +// Default: YES +@property (nonatomic, assign, getter=shouldSendUserData) BOOL sendUserData; + +// Send usage time to HockeyApp when checking for a new version; works only +// for beta apps and should not be activated for live apps. +// +// Default: YES +@property (nonatomic, assign, getter=shouldSendUsageTime) BOOL sendUsageTime; + +// Enable to allow the user to change the settings from the update view +// +// Default: YES +@property (nonatomic, assign, getter=shouldShowUserSettings) BOOL showUserSettings; + +// Allow the user to disable the sending of user data; this settings should +// only be set if showUserSettings is enabled. +// +// Default: YES +@property (nonatomic, assign, getter=isUserAllowedToDisableSendData) BOOL allowUserToDisableSendData; + +// Enable to show the new version alert every time the app becomes active and +// the current version is outdated +// +// Default: YES +@property (nonatomic, assign) BOOL alwaysShowUpdateReminder; + +// Enable to check for a new version every time the app becomes active; if +// disabled you need to trigger the update mechanism manually +// +// Default: YES +@property (nonatomic, assign, getter=shouldCheckForUpdateOnLaunch) BOOL checkForUpdateOnLaunch; + +// Show a button "Install" in the update alert to let the user directly start +// the update; note that the user will not see the release notes. +// +// Default: NO +@property (nonatomic, assign, getter=isShowingDirectInstallOption) BOOL showDirectInstallOption; + +// Enable to check on the server that the app is authorized to run on this +// device; the check is based on the UDID and the authentication secret which +// is shown on the app page on HockeyApp +// +// Default: NO +@property (nonatomic, assign, getter=shouldRequireAuthorization) BOOL requireAuthorization; + +// Set to the authentication secret which is shown on the app page on HockeyApp; +// must be set if requireAuthorization is enabled; leave empty otherwise +// +// Default: nil +@property (nonatomic, retain) NSString *authenticationSecret; + +// Define how the client determines if a new version is available. +// +// Values: +// HockeyComparisonResultDifferent - the version on the server is different +// HockeyComparisonResultGreate - the version on the server is greater +// +// Default: HockeyComparisonResultGreater +@property (nonatomic, assign) HockeyComparisonResult compareVersionType; + +#pragma mark - Public Methods + // Returns the shared manager object + (CNSHockeyManager *)sharedHockeyManager; @@ -132,4 +207,32 @@ // Returns true if the app crashes in the last session - (BOOL)didCrashInLastSession; +// Returns true if an update is available +- (BOOL)isUpdateAvailable; + +// Returns true if update check is running +- (BOOL)isCheckInProgress; + +// Show update info view +- (void)showUpdateView; + +// Manually start an update check +- (void)checkForUpdate; + +// Checks for update and informs the user if an update was found or an +// error occurred +- (void)checkForUpdateShowFeedback:(BOOL)feedback; + +// Initiates app-download call; this displays an alert view of the OS +- (BOOL)initiateAppDownload; + +// Returns true if this app version was authorized with the server +- (BOOL)appVersionIsAuthorized; + +// Manually check if the device is authorized to run this version +- (void)checkForAuthorization; + +// Return a new instance of BWHockeyViewController +- (BWHockeyViewController *)hockeyViewController:(BOOL)modal; + @end diff --git a/Classes/CNSHockeyManager.m b/Classes/CNSHockeyManager.m index 3438663bae..55b4b01028 100644 --- a/Classes/CNSHockeyManager.m +++ b/Classes/CNSHockeyManager.m @@ -147,6 +147,14 @@ } } +- (BOOL)isLoggingEnabled { + return [[BWHockeyManager sharedHockeyManager] isLoggingEnabled]; +} + +- (void)setLoggingEnabled:(BOOL)loggingEnabled { + return [[BWHockeyManager sharedHockeyManager] setLoggingEnabled:loggingEnabled]; +} + #pragma mark - Public Instance Methods (Crash Reporting) - (NSString *)languageStyle { @@ -193,6 +201,124 @@ return [[BWQuincyManager sharedQuincyManager] didCrashInLastSession]; } +#pragma mark - Public Instance Methods (Distribution) + +- (BOOL)shouldSendUserData { + return [[BWHockeyManager sharedHockeyManager] shouldSendUserData]; +} + +- (void)setSendUserData:(BOOL)sendUserData { + [[BWHockeyManager sharedHockeyManager] setSendUserData:sendUserData]; +} + +- (BOOL)shouldSendUsageTime { + return [[BWHockeyManager sharedHockeyManager] shouldSendUsageTime]; +} + +- (void)setSendUsageTime:(BOOL)sendUsageTime { + [[BWHockeyManager sharedHockeyManager] setSendUsageTime:sendUsageTime]; +} + +- (BOOL)shouldShowUserSettings { + return [[BWHockeyManager sharedHockeyManager] shouldShowUserSettings]; +} + +- (void)setShowUserSettings:(BOOL)showUserSettings { + [[BWHockeyManager sharedHockeyManager] setShowUserSettings:showUserSettings]; +} + +- (BOOL)isUserAllowedToDisableSendData { + return [[BWHockeyManager sharedHockeyManager] isAllowUserToDisableSendData]; +} + +- (void)setAllowUserToDisableSendData:(BOOL)allowUserToDisableSendData { + [[BWHockeyManager sharedHockeyManager] setAllowUserToDisableSendData:allowUserToDisableSendData]; +} + +- (BOOL)alwaysShowUpdateReminder { + return [[BWHockeyManager sharedHockeyManager] alwaysShowUpdateReminder]; +} + +- (void)setAlwaysShowUpdateReminder:(BOOL)alwaysShowUpdateReminder { + [[BWHockeyManager sharedHockeyManager] setAlwaysShowUpdateReminder:alwaysShowUpdateReminder]; +} + +- (BOOL)shouldCheckForUpdateOnLaunch { + return [[BWHockeyManager sharedHockeyManager] isCheckForUpdateOnLaunch]; +} + +- (void)setCheckForUpdateOnLaunch:(BOOL)checkForUpdateOnLaunch { + [[BWHockeyManager sharedHockeyManager] setCheckForUpdateOnLaunch:checkForUpdateOnLaunch]; +} + +- (BOOL)isShowingDirectInstallOption { + return [[BWHockeyManager sharedHockeyManager] isShowingDirectInstallOption]; +} + +- (void)setShowDirectInstallOption:(BOOL)showDirectInstallOption { + [[BWHockeyManager sharedHockeyManager] setShowDirectInstallOption:showDirectInstallOption]; +} + +- (BOOL)shouldRequireAuthorization { + return [[BWHockeyManager sharedHockeyManager] isRequireAuthorization]; +} + +- (void)setRequireAuthorization:(BOOL)requireAuthorization { + [[BWHockeyManager sharedHockeyManager] setRequireAuthorization:requireAuthorization]; +} + +- (NSString *)authenticationSecret { + return [[BWHockeyManager sharedHockeyManager] authenticationSecret]; +} + +- (void)setAuthenticationSecret:(NSString *)authenticationSecret { + [[BWHockeyManager sharedHockeyManager] setAuthenticationSecret:authenticationSecret]; +} + +- (HockeyComparisonResult)compareVersionType { + return [[BWHockeyManager sharedHockeyManager] compareVersionType]; +} + +- (void)setCompareVersionType:(HockeyComparisonResult)compareVersionType { + [[BWHockeyManager sharedHockeyManager] setCompareVersionType:compareVersionType]; +} + +- (BOOL)isUpdateAvailable { + return [[BWHockeyManager sharedHockeyManager] isUpdateAvailable]; +} + +- (BOOL)isCheckInProgress { + return [[BWHockeyManager sharedHockeyManager] isCheckInProgress]; +} + +- (void)showUpdateView { + [[BWHockeyManager sharedHockeyManager] showUpdateView]; +} + +- (void)checkForUpdate { + [[BWHockeyManager sharedHockeyManager] checkForUpdate]; +} + +- (void)checkForUpdateShowFeedback:(BOOL)feedback { + [[BWHockeyManager sharedHockeyManager] checkForUpdateShowFeedback:feedback]; +} + +- (BOOL)initiateAppDownload { + return [[BWHockeyManager sharedHockeyManager] initiateAppDownload]; +} + +- (BOOL)appVersionIsAuthorized { + return [[BWHockeyManager sharedHockeyManager] appVersionIsAuthorized]; +} + +- (void)checkForAuthorization { + [[BWHockeyManager sharedHockeyManager] checkForAuthorization]; +} + +- (BWHockeyViewController *)hockeyViewController:(BOOL)modal { + return [[BWHockeyManager sharedHockeyManager] hockeyViewController:modal]; +} + #pragma mark - Private Instance Methods - (BOOL)shouldUseLiveIdenfitier {