You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2012/06/20 21:15:50 UTC

ios commit: Fixed CB-748 - refactored-UUID is broken and changes over time (changed according to Apple's guidelines for this)

Updated Branches:
  refs/heads/master 32612280d -> 586e50a0a


Fixed CB-748 - refactored-UUID is broken and changes over time (changed according to Apple's guidelines for this)


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/586e50a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/586e50a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/586e50a0

Branch: refs/heads/master
Commit: 586e50a0a901426d44636208b358c0816c0503f2
Parents: 3261228
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Jun 20 12:15:41 2012 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Jun 20 12:15:41 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/UIDevice+Extensions.m |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/586e50a0/CordovaLib/Classes/UIDevice+Extensions.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/UIDevice+Extensions.m b/CordovaLib/Classes/UIDevice+Extensions.m
index 140e20a..91c714b 100644
--- a/CordovaLib/Classes/UIDevice+Extensions.m
+++ b/CordovaLib/Classes/UIDevice+Extensions.m
@@ -24,11 +24,24 @@
 
 - (NSString*) uniqueAppInstanceIdentifier
 {
-    // full path to the app folder
-    NSString* bundlePath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
+    NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
+    static NSString* UUID_KEY = @"CDVUUID";
     
-    // return only the folder name (a GUID)
-    return [bundlePath lastPathComponent];
+    NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
+    if (app_uuid == nil)
+    {
+        CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
+        CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
+
+        app_uuid = [NSString stringWithString:(NSString*)uuidString];
+        [userDefaults setObject:app_uuid forKey:UUID_KEY];
+        [userDefaults synchronize];
+        
+        CFRelease(uuidString);
+        CFRelease(uuidRef);
+    }
+    
+    return app_uuid;
 }
 
 @end