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