objc2_app_tracking_transparency/generated/mod.rs
1// This file has been automatically generated by `objc2`'s `header-translator`.
2// DO NOT EDIT
3
4#![allow(unused_imports)]
5#![allow(deprecated)]
6#![allow(non_snake_case)]
7#![allow(non_camel_case_types)]
8#![allow(non_upper_case_globals)]
9#![allow(missing_docs)]
10#![allow(clippy::too_many_arguments)]
11#![allow(clippy::type_complexity)]
12#![allow(clippy::upper_case_acronyms)]
13#![allow(clippy::identity_op)]
14#![allow(clippy::missing_safety_doc)]
15#![allow(clippy::doc_lazy_continuation)]
16#![allow(rustdoc::broken_intra_doc_links)]
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::unportable_markdown)]
19#![allow(rustdoc::invalid_html_tags)]
20
21#[link(name = "AppTrackingTransparency", kind = "framework")]
22extern "C" {}
23
24use core::ffi::*;
25use core::ptr::NonNull;
26use objc2::__framework_prelude::*;
27
28use crate::*;
29
30/// The status values for app tracking authorization.
31///
32/// After a device receives an authorization request to approve access to app-related
33/// data that can be used for tracking the user or the device, the returned value is
34/// either:
35///
36/// - ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/authorized``, or
37/// - ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/denied``.
38///
39/// Before a device receives an authorization request to approve access to app-related
40/// data that can be used for tracking the user or the device, the returned value is:
41/// ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/notDetermined``.
42///
43/// If authorization to use app tracking data is restricted, the value is: ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/restricted``.
44///
45/// See also [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanagerauthorizationstatus?language=objc)
46// NS_ENUM
47#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct ATTrackingManagerAuthorizationStatus(pub NSUInteger);
50impl ATTrackingManagerAuthorizationStatus {
51 /// The value that returns when the app can’t determine the user’s
52 /// authorization status for access to app-related data for tracking the
53 /// user or the device.
54 ///
55 /// - Note: If you call `ATTrackingManager.trackingAuthorizationStatus` in
56 /// macOS, the result is always `ATTrackingManager.AuthorizationStatus.notDetermined`.
57 #[doc(alias = "ATTrackingManagerAuthorizationStatusNotDetermined")]
58 pub const NotDetermined: Self = Self(0);
59 /// The value that returns if authorization to access app-related data for
60 /// tracking the user or the device has a restricted status.
61 ///
62 /// A restricted condition means the device does not prompt for tracking
63 /// authorization when
64 /// ``ATTrackingManager/requestTrackingAuthorizationWithCompletionHandler:``
65 /// is called, nor is it displayed when the
66 /// <doc
67 /// ://com.apple.documentation/documentation/bundleresources/information_property_list/NSUserTrackingUsageDescription>
68 /// is triggered. Also, on restricted devices, the Allow Apps To Request To
69 /// Track setting is disabled and cannot be changed. This setting allows
70 /// users to opt in or out of allowing apps to request user consent to
71 /// access app-related data that can be used for tracking the user or the
72 /// device.
73 #[doc(alias = "ATTrackingManagerAuthorizationStatusRestricted")]
74 pub const Restricted: Self = Self(1);
75 /// The value that returns if the user denies authorization to access
76 /// app-related data for tracking the user or the device.
77 ///
78 /// The end user has denied the authorization request to access app-related
79 /// data that can be used for tracking the user or the device.
80 #[doc(alias = "ATTrackingManagerAuthorizationStatusDenied")]
81 pub const Denied: Self = Self(2);
82 /// The value that returns if the user authorizes access to app-related data for
83 /// tracking the user or the device.
84 ///
85 /// This setting allows users to opt in or out of allowing apps to request user
86 /// consent to access app-related data for tracking the user or the device. End
87 /// users can revoke permission at any time through the Allow Apps to Request to
88 /// Track privacy setting on the device.
89 #[doc(alias = "ATTrackingManagerAuthorizationStatusAuthorized")]
90 pub const Authorized: Self = Self(3);
91}
92
93unsafe impl Encode for ATTrackingManagerAuthorizationStatus {
94 const ENCODING: Encoding = NSUInteger::ENCODING;
95}
96
97unsafe impl RefEncode for ATTrackingManagerAuthorizationStatus {
98 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
99}
100
101extern_class!(
102 /// A class that provides a tracking authorization request and the tracking
103 /// authorization status of the app.
104 ///
105 /// See also [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager?language=objc)
106 #[unsafe(super(NSObject))]
107 #[derive(Debug, PartialEq, Eq, Hash)]
108 pub struct ATTrackingManager;
109);
110
111extern_conformance!(
112 unsafe impl NSObjectProtocol for ATTrackingManager {}
113);
114
115impl ATTrackingManager {
116 extern_methods!(
117 /// The authorization status that is current for the calling application.
118 ///
119 /// If the user has not yet been prompted to approve access, the return value
120 /// will either be ``ATTrackingManagerAuthorizationStatusNotDetermined``, or
121 /// ``ATTrackingManagerAuthorizationStatusRestricted`` if this value is
122 /// managed. Once the user has been prompted, the return value will be either
123 /// ``ATTrackingManagerAuthorizationStatusDenied`` or
124 /// ``ATTrackingManagerAuthorizationStatusAuthorized``.
125 ///
126 /// Use the ``ATTrackingManager/trackingAuthorizationStatus`` property to check
127 /// authorization status.
128 ///
129 /// - Returns: Information about your application’s tracking authorization
130 /// status. Users are able to grant or deny developers tracking privileges on
131 /// a per-app basis. Application developers must call
132 /// `requestTrackingAuthorizationWithCompletionHandler:` for the ability to
133 /// track users.
134 #[unsafe(method(trackingAuthorizationStatus))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn trackingAuthorizationStatus() -> ATTrackingManagerAuthorizationStatus;
137
138 #[cfg(feature = "block2")]
139 /// The request for user authorization to access app-related data.
140 ///
141 /// The ``ATTrackingManager/requestTrackingAuthorizationWithCompletionHandler:``
142 /// is a one-time request to authorize or deny access to app-related data that
143 /// can be used for tracking the user or the device. The system remembers the
144 /// user’s choice and doesn’t prompt again unless a user uninstalls and then
145 /// reinstalls the app on the device.
146 ///
147 /// Calls to the API only prompt when the application state
148 /// is `UIApplicationStateActive`. The authorization prompt doesn’t display if
149 /// another permission request is pending user confirmation. Concurrent requests
150 /// aren’t preserved by iOS, and calls to the API through an app extension don’t
151 /// prompt. Check the ``ATTrackingManager/trackingAuthorizationStatus`` for a
152 /// status of
153 /// ``ATTrackingManagerAuthorizationStatus/ATTrackingManagerAuthorizationStatusNotDetermined``
154 /// to determine if you need to make an additional call.
155 ///
156 /// The completion handler will be called with the result of the user's
157 /// decision for granting or denying permission to use application tracking.
158 /// The completion handler will be called immediately if access to request
159 /// authorization is restricted.
160 ///
161 /// - Important: To use
162 /// ``ATTrackingManager/requestTrackingAuthorizationWithCompletionHandler:``,
163 /// the
164 /// <doc
165 /// ://com.apple.documentation/documentation/bundleresources/information_property_list/NSUserTrackingUsageDescription>
166 /// key must be in the
167 /// <doc
168 /// ://com.apple.documentation/documentation/bundleresources/information_property_list>.
169 #[unsafe(method(requestTrackingAuthorizationWithCompletionHandler:))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn requestTrackingAuthorizationWithCompletionHandler(
172 completion: &block2::DynBlock<dyn Fn(ATTrackingManagerAuthorizationStatus)>,
173 );
174
175 #[unsafe(method(new))]
176 #[unsafe(method_family = new)]
177 pub unsafe fn new() -> Retained<Self>;
178
179 #[unsafe(method(init))]
180 #[unsafe(method_family = init)]
181 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
182 );
183}
184
185extern "C" {
186 /// [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/apptrackingtransparencyversionnumber?language=objc)
187 pub static AppTrackingTransparencyVersionNumber: c_double;
188}
189
190extern "C" {
191 /// [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/apptrackingtransparencyversionstring?language=objc)
192 pub static AppTrackingTransparencyVersionString: *mut c_uchar;
193}