|
53 | 53 |
|
54 | 54 | #include "mblstore.h" |
55 | 55 |
|
| 56 | +#import <objc/message.h> |
| 57 | + |
56 | 58 | //////////////////////////////////////////////////////////////////////////////// |
57 | 59 |
|
58 | 60 | // global counter for the iPhone idle timer |
59 | 61 | uint g_idle_timer = 0; |
60 | 62 |
|
61 | | -id objc_lookUpClass(const char *name); |
62 | | - |
63 | 63 | bool MCParseParameters(MCParameter*& p_parameters, const char *p_format, ...) |
64 | 64 | { |
65 | 65 | MCExecPoint ep(nil, nil, nil); |
@@ -949,12 +949,30 @@ static Exec_stat MCHandleClearTouches(void *context, MCParameter *p_parameters) |
949 | 949 |
|
950 | 950 | //////////////////////////////////////////////////////////////////////////////// |
951 | 951 |
|
952 | | -static Exec_stat MCHandeSystemIdentifier(void *context, MCParameter *p_parameters) |
| 952 | +static Exec_stat MCHandleSystemIdentifier(void *context, MCParameter *p_parameters) |
953 | 953 | { |
954 | | - NSString *t_identifier = nil; |
955 | | - t_identifier = [[UIDevice currentDevice] uniqueIdentifier]; |
956 | | - MCresult -> copysvalue([t_identifier cStringUsingEncoding: NSMacOSRomanStringEncoding]); |
957 | | - return ES_NORMAL; |
| 954 | + // MM-2013-05-21: [[ Bug 10895 ]] The method uniqueIdentifier of UIDevice is now deprecated (as of May 2013). |
| 955 | + // Calling the method dynamically prevents apps from being rejected by the app store |
| 956 | + // but preserves functionality for testing and backwards compatibility. |
| 957 | + NSString *t_identifier; |
| 958 | + t_identifier = objc_msgSend([UIDevice currentDevice], sel_getUid("uniqueIdentifier")); |
| 959 | + MCresult -> copysvalue([t_identifier cStringUsingEncoding: NSMacOSRomanStringEncoding]); |
| 960 | + return ES_NORMAL; |
| 961 | +} |
| 962 | + |
| 963 | +// MM-2013-05-21: [[ Bug 10895 ]] Added iphoneIdentifierForVendor as an initial replacement for iphoneSystemIdentifier. |
| 964 | +// identifierForVendor was only added to UIDevice in iOS 6.1 so make sure we weakly link. |
| 965 | +static Exec_stat MCHandleIdentifierForVendor(void *context, MCParameter *p_parameters) |
| 966 | +{ |
| 967 | + if ([UIDevice instancesRespondToSelector:@selector(identifierForVendor)]) |
| 968 | + { |
| 969 | + NSString *t_identifier; |
| 970 | + t_identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; |
| 971 | + MCresult -> copysvalue([t_identifier cStringUsingEncoding: NSMacOSRomanStringEncoding]); |
| 972 | + } |
| 973 | + else |
| 974 | + MCresult -> clear(); |
| 975 | + return ES_NORMAL; |
958 | 976 | } |
959 | 977 |
|
960 | 978 | static Exec_stat MCHandleApplicationIdentifier(void *context, MCParameter *p_parameters) |
@@ -1380,8 +1398,12 @@ static Exec_stat MCHandleSetAnimateAutorotation(void *context, MCParameter *p_pa |
1380 | 1398 | {false, "iphoneClearTouches", MCHandleClearTouches, nil}, |
1381 | 1399 | {false, "mobileClearTouches", MCHandleClearTouches, nil}, |
1382 | 1400 |
|
1383 | | - {false, "iphoneSystemIdentifier", MCHandeSystemIdentifier, nil}, |
| 1401 | + {false, "iphoneSystemIdentifier", MCHandleSystemIdentifier, nil}, |
1384 | 1402 | {false, "iphoneApplicationIdentifier", MCHandleApplicationIdentifier, nil}, |
| 1403 | + |
| 1404 | + // MM-2013-05-21: [[ Bug 10895 ]] Added iphoneIdentifierForVendor as an initial replacement for iphoneSystemIdentifier. |
| 1405 | + {false, "mobileIdentifierForVendor", MCHandleIdentifierForVendor, nil}, |
| 1406 | + {false, "iphoneIdentifierForVendor", MCHandleIdentifierForVendor, nil}, |
1385 | 1407 |
|
1386 | 1408 | {false, "iphoneSetReachabilityTarget", MCHandleSetReachabilityTarget, nil}, |
1387 | 1409 | {false, "iphoneReachabilityTarget", MCHandleReachabilityTarget, nil}, |
|
0 commit comments