Restructure UDID check

- Optional Macro HOCKEY_BLOCK_UDID to allow getting uniqueIdentifier, default to NOT allowed
- If Macro is not set, configuration is not Debug, AdHoc or Beta, require a delegate method
- Delegate method to return the device UDID, developer has to make sure it is not returned when building for AppStore
This commit is contained in:
Andreas Linde 2012-03-23 23:04:41 +01:00
parent 7705382f6b
commit f48c984eb6
4 changed files with 47 additions and 5 deletions

View File

@ -28,8 +28,8 @@
#define SDK_NAME @"HockeySDK"
#define SDK_VERSION @"2.2.6-develop"
#ifndef DONT_SEND_UDID
#define DONT_SEND_UDID 0
#ifndef HOCKEY_BLOCK_UDID
#define HOCKEY_BLOCK_UDID 1
#endif
// uncomment this line to enable NSLog-debugging output

View File

@ -25,6 +25,8 @@
#import <UIKit/UIKit.h>
#import "BWHockeyViewController.h"
#import "BWGlobal.h"
typedef enum {
HockeyComparisonResultDifferent,
@ -236,6 +238,24 @@ typedef enum {
///////////////////////////////////////////////////////////////////////////////////////////////////
@protocol BWHockeyManagerDelegate <NSObject>
#if HOCKEY_BLOCK_UDID == 0 || defined (CONFIGURATION_Debug1) || defined (CONFIGURATION_AdHoc) || defined (CONFIGURATION_Beta)
@optional
#endif
/*
Return the device UDID which is required for beta testing, should return nil for app store configuration!
The default implementation would be like:
#ifndef (CONFIGURATION_AppStore)
if ([[UIDevice currentDevice] respondsToSelector:@selector(uniqueIdentifier)])
return [[UIDevice currentDevice] performSelector:@selector(uniqueIdentifier)];
#endif
return nil;
*/
- (NSString *)customDeviceIdentifier;
@optional
// Invoked when the internet connection is started, to let the app enable the activity indicator

View File

@ -23,7 +23,6 @@
// THE SOFTWARE.
#import "BWHockeyManager.h"
#import "BWGlobal.h"
#import "BWApp.h"
#import "NSString+HockeyAdditions.h"
#import "UIImage+HockeyAdditions.h"
@ -238,11 +237,18 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
}
- (NSString *)deviceIdentifier {
#if DONT_SEND_UDID == 0
#if HOCKEY_BLOCK_UDID == 0 || defined (CONFIGRATION_Debug1) || defined (CONFIGRATION_AdHoc) || defined (CONFIGURATION_Beta)
if ([[UIDevice currentDevice] respondsToSelector:@selector(uniqueIdentifier)])
return [[UIDevice currentDevice] performSelector:@selector(uniqueIdentifier)];
#endif
if ([delegate_ respondsToSelector:@selector(customDeviceIdentifier)]) {
NSString *identifier = [delegate_ performSelector:@selector(customDeviceIdentifier)];
if (identifier && [identifier length] > 0) {
return identifier;
}
}
return @"invalid";
}

View File

@ -25,6 +25,22 @@
@protocol CNSHockeyManagerDelegate <NSObject>
#if HOCKEY_BLOCK_UDID == 0 || defined (CONFIGURATION_Debug1) || defined (CONFIGURATION_AdHoc) || defined (CONFIGURATION_Beta)
@optional
#endif
/*
Return the device UDID which is required for beta testing, should return nil for app store configuration!
The default implementation would be like:
#ifndef (CONFIGURATION_AppStore)
if ([[UIDevice currentDevice] respondsToSelector:@selector(uniqueIdentifier)])
return [[UIDevice currentDevice] performSelector:@selector(uniqueIdentifier)];
#endif
return nil;
*/
- (NSString *)customDeviceIdentifier;
@optional
// Invoked when the manager is configured