Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Commit f557b5f

Browse files
Fixed bug 10895 - apps rejected from app store for use of deprecated UDID functionality.
Added new handler mobileIdentifierForVendor as an initial replacement for iphoneSystemIdentifier.
1 parent dba0010 commit f557b5f

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

engine/src/mbliphoneextra.mm

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353

5454
#include "mblstore.h"
5555

56+
#import <objc/message.h>
57+
5658
////////////////////////////////////////////////////////////////////////////////
5759

5860
// global counter for the iPhone idle timer
5961
uint g_idle_timer = 0;
6062

61-
id objc_lookUpClass(const char *name);
62-
6363
bool MCParseParameters(MCParameter*& p_parameters, const char *p_format, ...)
6464
{
6565
MCExecPoint ep(nil, nil, nil);
@@ -949,12 +949,30 @@ static Exec_stat MCHandleClearTouches(void *context, MCParameter *p_parameters)
949949

950950
////////////////////////////////////////////////////////////////////////////////
951951

952-
static Exec_stat MCHandeSystemIdentifier(void *context, MCParameter *p_parameters)
952+
static Exec_stat MCHandleSystemIdentifier(void *context, MCParameter *p_parameters)
953953
{
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;
958976
}
959977

960978
static Exec_stat MCHandleApplicationIdentifier(void *context, MCParameter *p_parameters)
@@ -1380,8 +1398,12 @@ static Exec_stat MCHandleSetAnimateAutorotation(void *context, MCParameter *p_pa
13801398
{false, "iphoneClearTouches", MCHandleClearTouches, nil},
13811399
{false, "mobileClearTouches", MCHandleClearTouches, nil},
13821400

1383-
{false, "iphoneSystemIdentifier", MCHandeSystemIdentifier, nil},
1401+
{false, "iphoneSystemIdentifier", MCHandleSystemIdentifier, nil},
13841402
{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},
13851407

13861408
{false, "iphoneSetReachabilityTarget", MCHandleSetReachabilityTarget, nil},
13871409
{false, "iphoneReachabilityTarget", MCHandleReachabilityTarget, nil},

0 commit comments

Comments
 (0)