Skip to content

Commit 8b524e0

Browse files
Merge pull request livecode#7562 from livecodepanos/bugfix-23193
[[ Bug 23193 ]] Add support for App Tracking Transparency
2 parents b40f836 + 8aa50c1 commit 8b524e0

15 files changed

+170
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Name: iphoneTrackingAuthorizationStatus
2+
3+
Type: function
4+
5+
Syntax: iphoneTrackingAuthorizationStatus()
6+
7+
Summary:
8+
Returns the current tracking authorization status of the calling
9+
application.
10+
11+
Introduced: 9.6.3
12+
13+
OS: ios
14+
15+
Platforms: mobile
16+
17+
Example:
18+
local tStatus
19+
put iphoneTrackingAuthorizationStatus() into tStatus
20+
if tStatus is "denied" then
21+
answer "The app cannot track you"
22+
end if
23+
24+
Returns (enum):
25+
The <iphoneTrackingAuthorizationStatus> function returns one of the
26+
following strings:
27+
28+
- "not determined" - The user has not yet received a request to authorize access to
29+
app-related data that can be used for tracking the user or the device.
30+
- "restricted" - Authorization to access app-related data that can be used for tracking
31+
the user or the device is restricted.
32+
- "denied" - User has explicitly denied authorization to access app-related data that
33+
can be used for tracking the user or the device.
34+
- "authorized" - User has granted access to app-related data that can be used for
35+
tracking the user or the device.
36+
- "not supported" - Device runs a version of iOS lower than 14, where this
37+
feature is not supported
38+
39+
40+
Description:
41+
Use the <iphoneTrackingAuthorizationStatus> function to find the current
42+
tracking authorization status of the calling application.
43+
44+
This function is available in iOS 14 and above.
45+
46+

docs/notes/bugfix-23193.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Added support for App Tracking Transparency on iOS
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Support for App Tracking Transparency
2+
3+
The Standalone Builder now includes a checkbox that adds support for App Tracking Transparency.
4+
This is a requirement if your app collects user data that is shared among apps or websites.
5+
Moreover, a text field is added, where you can provide the usage description string, i.e. the dialog
6+
text that will be presented to the user letting them know that their data will be shared.

engine/kernel.gyp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@
185185
'$(SDKROOT)/System/Library/Frameworks/MediaToolbox.framework',
186186
],
187187
},
188+
],
189+
[
190+
'OS == "ios" and target_sdk >= "14.0"',
191+
{
192+
'libraries':
193+
[
194+
'$(SDKROOT)/System/Library/Frameworks/AppTrackingTransparency.framework',
195+
],
196+
},
188197
],
189198
[
190199
'OS == "ios"',

engine/rsrc/mobile-device-template.plist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
<key>NSBluetoothAlwaysUsageDescription</key>
131131
<string>This application requires access to Bluetooth always</string>
132132
${HEALTHKIT}
133+
${APP_TRACKING_TRANSPARENCY}
133134
<key>LSApplicationQueriesSchemes</key>
134135
<array>
135136
${APP_URL_WHITELIST}

engine/rsrc/mobile-template.plist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<string>This application requires access to Photo Library</string>
9595
<key>NSBluetoothAlwaysUsageDescription</key>
9696
<string>This application requires access to Bluetooth always</string>
97+
${APP_TRACKING_TRANSPARENCY}
9798
${HEALTHKIT}
9899
${UI_STYLE}
99100
</dict>

engine/src/exec-misc.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ void MCMiscGetDeviceToken(MCExecContext& ctxt, MCStringRef& r_token)
6767
ctxt.Throw();
6868
}
6969

70+
void MCMiscGetTrackingAuthorizationStatus(MCExecContext& ctxt, MCStringRef& r_status)
71+
{
72+
if(MCSystemGetTrackingAuthorizationStatus(r_status))
73+
return;
74+
75+
ctxt.Throw();
76+
}
77+
7078
void MCMiscGetLaunchUrl(MCExecContext& ctxt, MCStringRef& r_url)
7179
{
7280
if(MCSystemGetLaunchUrl(r_url))

engine/src/exec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4006,6 +4006,8 @@ void MCSoundSetAudioCategory(MCExecContext &ctxt, intenum_t p_category);
40064006

40074007
extern MCExecEnumTypeInfo* kMCMiscStatusBarStyleTypeInfo;
40084008

4009+
void MCMiscGetTrackingAuthorizationStatus(MCExecContext& ctxt, MCStringRef &r_status);
4010+
40094011
void MCMiscGetDeviceToken(MCExecContext& ctxt, MCStringRef& r_token);
40104012
void MCMiscGetLaunchUrl(MCExecContext& ctxt, MCStringRef& r_url);
40114013

engine/src/mblandroidmisc.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,12 @@ bool MCSystemGetSystemIdentifier(MCStringRef& r_identifier)
679679
return false;
680680
}
681681

682+
bool MCSystemGetTrackingAuthorizationStatus (MCStringRef& r_status)
683+
{
684+
// not supported on Android
685+
return false;
686+
}
687+
682688
bool MCSystemGetApplicationIdentifier(MCStringRef& r_identifier)
683689
{
684690
// not implemented on Android

engine/src/mblhandlers.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,6 +2906,23 @@ static Exec_stat MCHandleLocationAuthorizationStatus(void *context, MCParameter
29062906
return ES_ERROR;
29072907
}
29082908

2909+
static Exec_stat MCHandleTrackingAuthorizationStatus(void *context, MCParameter *p_parameters)
2910+
{
2911+
MCAutoStringRef t_status;
2912+
MCExecContext ctxt(nil, nil,nil);
2913+
2914+
MCMiscGetTrackingAuthorizationStatus(ctxt, &t_status);
2915+
2916+
if (!ctxt . HasError())
2917+
{
2918+
ctxt . SetTheResultToValue(*t_status);
2919+
return ES_NORMAL;
2920+
}
2921+
2922+
ctxt . SetTheResultToEmpty();
2923+
return ES_ERROR;
2924+
}
2925+
29092926

29102927
static MCMiscStatusBarStyle MCMiscStatusBarStyleFromString(MCStringRef p_string)
29112928
{
@@ -4672,6 +4689,8 @@ static const MCPlatformMessageSpec s_platform_messages[] =
46724689
{false, "mobileUseDeviceResolution", MCHandleUseDeviceResolution, nil},
46734690
{false, "mobileDeviceScale", MCHandleDeviceScale, nil},
46744691
{false, "mobilePixelDensity", MCHandlePixelDensity, nil},
4692+
4693+
{false, "iphoneTrackingAuthorizationStatus", MCHandleTrackingAuthorizationStatus, nil},
46754694

46764695
// SN-2014-10-15: [[ Merge-6.7.0-rc-3 ]]
46774696
{false, "iphoneLocationAuthorizationStatus", MCHandleLocationAuthorizationStatus, nil},

0 commit comments

Comments
 (0)