Difference between revisions of "UIDevice"

From iPhone Development Wiki
Jump to: navigation, search
(LS Identifiers)
(changing link text again, to more clearly indicate the content of the target link)
 
(9 intermediate revisions by 4 users not shown)
Line 19: Line 19:
 
|-
 
|-
 
| name || kLockdownDeviceNameKey
 
| name || kLockdownDeviceNameKey
|-
 
| identifierForVendor || unknown
 
|-
 
| advertisingIdentifier || unknown
 
 
|}
 
|}
  
== iPad mode (Wild cat) ==
+
== iPad mode (Wildcat) ==
 
{{function signature
 
{{function signature
 
|signature=@property(assign,nonatomic) BOOL isWildcat;
 
|signature=@property(assign,nonatomic) BOOL isWildcat;
 
|firmware=3.2 —
 
|firmware=3.2 —
 
}}
 
}}
iPad has a drastically different user interface than iPhone/iPod Touch, but all three share the same OS. In UIKit and {{fwlink|SpringBoard}}, this property is heavily used to determine which behavior should be used.
+
iPad (codenamed Wildcat) has a drastically different user interface than iPhone/iPod Touch, but all three share the same OS. In UIKit and {{fwlink|SpringBoard}}, this property is heavily used to determine which behavior should be used.
 +
 
 +
You should check against the public <code>userInterfaceIdiom</code> instead of using this property.
  
Wild cat is the codename of iPad.
+
== lsdidentifiers (Launch Services Daemon Identifiers) ==
  
== LaunchServices (LS) Identifiers ==
+
The identifiers are stored in the following file: <code>/private/var/db/lsd/com.apple.lsdidentifiers.plist</code>
  
The identifiers are stored in the following file:
+
The launch services daemon (lsd) manages this file.
/private/var/db/lsd/com.apple.lsdidentifiers.plist
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! property !! lsidentifiers key
+
! property !! lsdidentifiers key
 
|-
 
|-
 
| advertisingIdentifier || LSAdvertiserIdentifier
 
| advertisingIdentifier || LSAdvertiserIdentifier
Line 49: Line 46:
 
| identifierForVendor Xcode deployed app || BundleID:[first parts of app's bundle ID] (e.g. com.malcolmhall)
 
| identifierForVendor Xcode deployed app || BundleID:[first parts of app's bundle ID] (e.g. com.malcolmhall)
 
|-
 
|-
| identifierForVendor \Applications app or daemon || Path:[ExecutableName] (e.g. Path:pmpd)
+
| identifierForVendor /Applications app or daemon || Path:[ExecutableName] (e.g. Path:pmpd)
 
|}
 
|}
  
Line 63: Line 60:
 
|}
 
|}
  
 +
It appears that when you install your app to /Applications, LaunchServices fills in the "identifierForVendor Xcode deployed app". However when you actually run your app and access the identifier, it then fills in the "identifierForVendor /Applications app" with a different ID and the app uses that one. This means you can't share the same ID for an app you are developing by both deploying from Xcode and also copying to /Applications.
 +
 +
A way to access the real identifierForVendor within an app launched from /Applications is to give the app the entitlement com.apple.lsapplicationproxy.deviceidentifierforvendor. Then add this:
  
It appears that when you install your app to \Applications and respiring (using BigBoss's Respring App) it fills in the "identifierForVendor Xcode deployed app". However when you actually run your app it then fills in the "identifierForVendor \Applications app" with a different ID and the app uses that one. This means you can't share the same ID for an app you are developing by both deploying from Xcode and also copying to \Applications.
+
<source lang=objc>
 +
@interface LSApplicationProxy
 +
+(id)applicationProxyForIdentifier:(id)arg1;
 +
-(NSUUID*)deviceIdentifierForVendor;
 +
@end
 +
 +
NSString* realIdentifierForVendor = [[NSClassFromString(@"LSApplicationProxy") applicationProxyForIdentifier:[NSBundle mainBundle].bundleIdentifier] deviceIdentifierForVendor].UUIDString;
 +
</source>
  
These identifiers are backed up however they will change if the user restores their backup to a new device, according to the Apple docs but not fully verified. This stack overflow user has done some testing: http://stackoverflow.com/questions/16520231/under-what-conditions-is-apples-advertisingidentifier-reset
+
These identifiers are backed up, however they will change if the user restores their backup to a new device, according to the Apple docs (but not fully verified). A Stack Overflow user [http://stackoverflow.com/questions/16520231/under-what-conditions-is-apples-advertisingidentifier-reset has done some testing].
  
 
== References ==
 
== References ==
 
* Official reference: {{sdklink|UIKit|UIDevice}}
 
* Official reference: {{sdklink|UIKit|UIDevice}}
 
{{IPFHeader|UIKit|3=2}}
 
{{IPFHeader|UIKit|3=2}}

Latest revision as of 09:33, 21 January 2014

UIDevice is a singleton class that provides access to some properties of the current device.

As a client to liblockdown

Many important properties can be accessed via liblockdown. This can be used to bypass higher-level spoofing hacks. One has to use the liblockdown functions in MobileSubstrate initializers because UIKit was not ready at that time.

UIDevice property liblockdown key
model kLockdownDeviceClassKey
localizedModel kLockdownDeviceClassKey
uniqueIdentifier kLockdownUniqueDeviceIDKey
buildVersion kLockdownBuildVersionKey
systemVersion kLockdownProductVersionKey
name kLockdownDeviceNameKey

iPad mode (Wildcat)

Signature @property(assign,nonatomic) BOOL isWildcat;
Available in 3.2 —

iPad (codenamed Wildcat) has a drastically different user interface than iPhone/iPod Touch, but all three share the same OS. In UIKit and SpringBoard, this property is heavily used to determine which behavior should be used.

You should check against the public userInterfaceIdiom instead of using this property.

lsdidentifiers (Launch Services Daemon Identifiers)

The identifiers are stored in the following file: /private/var/db/lsd/com.apple.lsdidentifiers.plist

The launch services daemon (lsd) manages this file.

property lsdidentifiers key
advertisingIdentifier LSAdvertiserIdentifier
identifierForVendor AppStore app Vendor Name (e.g. Google, Inc.)
identifierForVendor Xcode deployed app BundleID:[first parts of app's bundle ID] (e.g. com.malcolmhall)
identifierForVendor /Applications app or daemon Path:[ExecutableName] (e.g. Path:pmpd)

Each lsidentifiers key (except advertising) contains a dictionary using following keys:

key description
LSVendorIdentifier a UUID (aka GUID)
LSApplications In the case of Path: it is the list of paths e.g. /private/var/stash/Applications.zcoj2b/UDIDTest4.app/UDIDTest4. In the case of BundleID:[com.vendor] or VendorName it is a list of bundle IDs.

It appears that when you install your app to /Applications, LaunchServices fills in the "identifierForVendor Xcode deployed app". However when you actually run your app and access the identifier, it then fills in the "identifierForVendor /Applications app" with a different ID and the app uses that one. This means you can't share the same ID for an app you are developing by both deploying from Xcode and also copying to /Applications.

A way to access the real identifierForVendor within an app launched from /Applications is to give the app the entitlement com.apple.lsapplicationproxy.deviceidentifierforvendor. Then add this:

@interface LSApplicationProxy 
+(id)applicationProxyForIdentifier:(id)arg1;
-(NSUUID*)deviceIdentifierForVendor;
@end
 
NSString* realIdentifierForVendor = [[NSClassFromString(@"LSApplicationProxy") applicationProxyForIdentifier:[NSBundle mainBundle].bundleIdentifier] deviceIdentifierForVendor].UUIDString;

These identifiers are backed up, however they will change if the user restores their backup to a new device, according to the Apple docs (but not fully verified). A Stack Overflow user has done some testing.

References