diff --git a/Classes/BITStoreUpdateManager.h b/Classes/BITStoreUpdateManager.h index 9941928d85..1b138e61d8 100644 --- a/Classes/BITStoreUpdateManager.h +++ b/Classes/BITStoreUpdateManager.h @@ -37,6 +37,8 @@ typedef enum { BITStoreUpdateCheckManually = 2 } BITStoreUpdateSetting; +@protocol BITStoreUpdateManagerDelegate; + /** The store update manager module. @@ -53,6 +55,16 @@ typedef enum { @interface BITStoreUpdateManager : BITHockeyBaseManager +///----------------------------------------------------------------------------- +/// @name Delegate +///----------------------------------------------------------------------------- + +/** + Sets the optional `BITStoreUpdateManagerDelegate` delegate. + */ +@property (nonatomic, weak) id delegate; + + ///----------------------------------------------------------------------------- /// @name Update Checking ///----------------------------------------------------------------------------- diff --git a/Classes/BITStoreUpdateManager.m b/Classes/BITStoreUpdateManager.m index f694fed702..9959dab777 100644 --- a/Classes/BITStoreUpdateManager.m +++ b/Classes/BITStoreUpdateManager.m @@ -266,8 +266,14 @@ return NO; } - if ([self isUpdateAvailable] && BITHockeyBundle()) { - [self showUpdateAlert]; + if ([self isUpdateAvailable]) { + if (self.delegate && [self.delegate respondsToSelector:@selector(detectedUpdateFromStoreUpdateManager:newVersion:)]) { + [self.delegate detectedUpdateFromStoreUpdateManager:self newVersion:_newStoreVersion]; + } + + if (BITHockeyBundle()) { + [self showUpdateAlert]; + } } return YES; diff --git a/Classes/BITStoreUpdateManagerDelegate.h b/Classes/BITStoreUpdateManagerDelegate.h new file mode 100644 index 0000000000..95fa8cac07 --- /dev/null +++ b/Classes/BITStoreUpdateManagerDelegate.h @@ -0,0 +1,56 @@ +/* + * Author: Andreas Linde + * + * Copyright (c) 2013 HockeyApp, Bit Stadium GmbH. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#import + +@class BITStoreUpdateManager; + +/** + The `BITStoreUpdateManagerDelegate` formal protocol defines methods for + more interaction with `BITStoreUpdateManager`. + */ + +@protocol BITStoreUpdateManagerDelegate + +@optional + + +///----------------------------------------------------------------------------- +/// @name Update information +///----------------------------------------------------------------------------- + +/** Informs which new version has been reported to be available + + @param storeUpdateManager The `BITStoreUpdateManager` instance invoking this delegate + @param version The new version string reported by the App Store + */ +-(void)detectedUpdateFromStoreUpdateManager:(BITStoreUpdateManager *)storeUpdateManager newVersion:(NSString *)newVersion; + + + +@end diff --git a/Classes/HockeySDK.h b/Classes/HockeySDK.h index 8c7a152afb..5e97cfd8d0 100644 --- a/Classes/HockeySDK.h +++ b/Classes/HockeySDK.h @@ -41,6 +41,7 @@ #import "BITUpdateViewController.h" #import "BITStoreUpdateManager.h" +#import "BITStoreUpdateManagerDelegate.h" #import "BITFeedbackManager.h" #import "BITFeedbackActivity.h" diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index fe69b04995..e3e8dcb3fd 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ /* Begin PBXBuildFile section */ 1E0FEE28173BDB260061331F /* BITKeychainUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E0FEE26173BDB260061331F /* BITKeychainUtils.h */; }; 1E0FEE29173BDB260061331F /* BITKeychainUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E0FEE27173BDB260061331F /* BITKeychainUtils.m */; }; + 1E0829001708F69A0073050E /* BITStoreUpdateManagerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E0828FF1708F69A0073050E /* BITStoreUpdateManagerDelegate.h */; }; 1E1127C416580C87007067A2 /* buttonRoundedDelete.png in Resources */ = {isa = PBXBuildFile; fileRef = 1E1127BC16580C87007067A2 /* buttonRoundedDelete.png */; }; 1E1127C516580C87007067A2 /* buttonRoundedDelete@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1E1127BD16580C87007067A2 /* buttonRoundedDelete@2x.png */; }; 1E1127C616580C87007067A2 /* buttonRoundedDeleteHighlighted.png in Resources */ = {isa = PBXBuildFile; fileRef = 1E1127BE16580C87007067A2 /* buttonRoundedDeleteHighlighted.png */; }; @@ -165,6 +166,7 @@ 1E0FEE22173BD9BB0061331F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 1E0FEE26173BDB260061331F /* BITKeychainUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITKeychainUtils.h; sourceTree = ""; }; 1E0FEE27173BDB260061331F /* BITKeychainUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITKeychainUtils.m; sourceTree = ""; }; + 1E0828FF1708F69A0073050E /* BITStoreUpdateManagerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITStoreUpdateManagerDelegate.h; sourceTree = ""; }; 1E1127BC16580C87007067A2 /* buttonRoundedDelete.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = buttonRoundedDelete.png; sourceTree = ""; }; 1E1127BD16580C87007067A2 /* buttonRoundedDelete@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "buttonRoundedDelete@2x.png"; sourceTree = ""; }; 1E1127BE16580C87007067A2 /* buttonRoundedDeleteHighlighted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = buttonRoundedDeleteHighlighted.png; sourceTree = ""; }; @@ -456,6 +458,7 @@ 1E94F9DF16E91330006570AD /* BITStoreUpdateManager.h */, 1E94F9E016E91330006570AD /* BITStoreUpdateManager.m */, 1E94F9E316E9136B006570AD /* BITStoreUpdateManagerPrivate.h */, + 1E0828FF1708F69A0073050E /* BITStoreUpdateManagerDelegate.h */, ); name = StoreUpdate; sourceTree = ""; @@ -581,6 +584,7 @@ 1E0FEE28173BDB260061331F /* BITKeychainUtils.h in Headers */, 1E94F9E116E91330006570AD /* BITStoreUpdateManager.h in Headers */, 1E94F9E416E9136B006570AD /* BITStoreUpdateManagerPrivate.h in Headers */, + 1E0829001708F69A0073050E /* BITStoreUpdateManagerDelegate.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; };