Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Important backwards compatible change for iOS 6 support

This commit will break the code, on purpose. Please read the important
note around the #error and fix it accordingly for iOS 6 if you can, if
not, comment it out!
  • Loading branch information...
commit 4b566c139b22f83d0186083e4141878864458238 1 parent a3840eb
Yann Lechelle authored
Showing with 42 additions and 7 deletions.
  1. +42 −7 OpenUDID.m
49 OpenUDID.m
View
@@ -3,7 +3,7 @@
// openudid
//
// initiated by Yann Lechelle (cofounder @Appsfire) on 8/28/11.
-// Copyright 2011 OpenUDID.org
+// Copyright 2011, 2012 OpenUDID.org
//
// Initiators/root branches
// iOS code: https://github.com/ylechelle/OpenUDID
@@ -42,6 +42,8 @@
// https://img.skitch.com/20120717-g3ag5h9a6ehkgpmpjiuen3qpwp.png
#endif
+#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
+
#import "OpenUDID.h"
#import <CommonCrypto/CommonDigest.h> // Need to import for CC_MD5 access
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
@@ -56,6 +58,7 @@
//#define OpenUDIDLog(fmt, ...) NSLog((@"[Line %d] " fmt), __LINE__, ##__VA_ARGS__);
static NSString * kOpenUDIDSessionCache = nil;
+static NSString * const kOpenUDIDDescription = @"OpenUDID_with_iOS6_Support";
static NSString * const kOpenUDIDKey = @"OpenUDID";
static NSString * const kOpenUDIDSlotKey = @"OpenUDID_slot";
static NSString * const kOpenUDIDAppUIDKey = @"OpenUDID_appUID";
@@ -115,14 +118,45 @@ + (NSString*) _generateFreshOpenUDID {
NSString* _openUDID = nil;
// August 2011: One day, this may no longer be allowed in iOS. When that is, just comment this line out.
- // March 25th 2012: this day has come, let's remove this "outlawed" call...
+ // March 25th 2012: this day has come, let's remove this "outlawed" call...
+ // August 2012: well, perhaps much ado about nothing; in any case WWDC2012 gave us something to work with; read below
#if TARGET_OS_IPHONE
// if([UIDevice instancesRespondToSelector:@selector(uniqueIdentifier)]){
// _openUDID = [[UIDevice currentDevice] uniqueIdentifier];
// }
#endif
+
+ //
+ // !!!!! IMPORTANT README !!!!!
+ //
+ // August 2012: iOS 6 introduces new APIs that help us deal with the now deprecated [UIDevice uniqueIdentifier]
+ // Since iOS 6 is still pre-release and under NDA, the following piece of code is meant to produce an error at
+ // compile time. Accredited developers integrating OpenUDID are expected to review the iOS 6 release notes and
+ // documentation, and replace the underscore ______ in the last part of the selector below with the right
+ // selector syntax as described here (make sure to use the right one! last word starts with the letter "A"):
+ // https://developer.apple.com/library/prerelease/ios/#documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html
+ //
+ // The semantic compiler warnings are still normal if you are compiling for iOS 5 only since Xcode will not
+ // know about the two instance methods used on that line; the code running on iOS will work well at run-time.
+ // Either way, it's time that you junped on the iOS 6 bandwagon and start testing your code on iOS 6 ;-)
+ //
+ // WHAT IS THE SIGNIFICANCE OF THIS CHANGE?
+ //
+ // Essentially, this means that OpenUDID will keep on behaving the same way as before for existing users or
+ // new users in iOS 5 and before. For new users on iOS 6 and after, the new official public APIs will take over.
+ // OpenUDID will therefore be obsoleted when iOS reaches significant adoption, anticipated around mid-2013.
+
+
+#if TARGET_OS_IPHONE
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
+ _openUDID = [[[UIDevice currentDevice] identifierForA_______] UUIDString];
+# error ^ read comments above, fix accordingly, and remove this #error line
+ }
+#endif
+
+
// Next we generate a UUID.
- // UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs
+ // UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs
// (Interface Identifiers), are 128-bit values guaranteed to be unique. A UUID is made unique over
// both space and time by combining a value unique to the computer on which it was generated—usually the
// Ethernet hardware address—and a value representing the number of 100-nanosecond intervals since
@@ -181,13 +215,14 @@ + (NSString*) valueWithError:(NSError **)error {
// The AppUID will uniquely identify this app within the pastebins
//
- NSString * appUID = (NSString *) [defaults objectForKey:kOpenUDIDAppUIDKey];
+ NSString * appUID = [defaults objectForKey:kOpenUDIDAppUIDKey];
if(appUID == nil)
{
// generate a new uuid and store it in user defaults
- CFUUIDRef uuid = CFUUIDCreate(NULL);
- appUID = (NSString *) CFUUIDCreateString(NULL, uuid);
- CFRelease(uuid);
+ CFUUIDRef uuid = CFUUIDCreate(NULL);
+ appUID = (NSString *) CFUUIDCreateString(NULL, uuid);
+ CFRelease(uuid);
+ [appUID autorelease];
}
NSString* openUDID = nil;
Please sign in to comment.
Something went wrong with that request. Please try again.