objc2-app-tracking-transparency 0.3.2

Bindings to the AppTrackingTransparency framework
Documentation
// This file has been automatically generated by `objc2`'s `header-translator`.
// DO NOT EDIT

#![allow(unused_imports)]
#![allow(deprecated)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(missing_docs)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::identity_op)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::doc_lazy_continuation)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::bare_urls)]
#![allow(rustdoc::invalid_html_tags)]

#[link(name = "AppTrackingTransparency", kind = "framework")]
extern "C" {}

use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// The status values for app tracking authorization.
///
/// After a device receives an authorization request to approve access to app-related
/// data that can be used for tracking the user or the device, the returned value is
/// either:
///
/// - ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/authorized``, or
/// - ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/denied``.
///
/// Before a device receives an authorization request to approve access to app-related
/// data that can be used for tracking the user or the device, the returned value is:
/// ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/notDetermined``.
///
/// If authorization to use app tracking data is restricted, the value is: ``AppTrackingTransparency/ATTrackingManager/AuthorizationStatus/restricted``.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanagerauthorizationstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ATTrackingManagerAuthorizationStatus(pub NSUInteger);
impl ATTrackingManagerAuthorizationStatus {
    /// The value that returns when the app can’t determine the user’s
    /// authorization status for access to app-related data for tracking the
    /// user or the device.
    ///
    /// - Note: If you call `ATTrackingManager.trackingAuthorizationStatus` in
    /// macOS, the result is always `ATTrackingManager.AuthorizationStatus.notDetermined`.
    #[doc(alias = "ATTrackingManagerAuthorizationStatusNotDetermined")]
    pub const NotDetermined: Self = Self(0);
    /// The value that returns if authorization to access app-related data for
    /// tracking the user or the device has a restricted status.
    ///
    /// A restricted condition means the device does not prompt for tracking
    /// authorization when
    /// ``ATTrackingManager/requestTrackingAuthorizationWithCompletionHandler:``
    /// is called, nor is it displayed when the
    /// <doc
    /// ://com.apple.documentation/documentation/bundleresources/information_property_list/NSUserTrackingUsageDescription>
    /// is triggered. Also, on restricted devices, the Allow Apps To Request To
    /// Track setting is disabled and cannot be changed. This setting allows
    /// users to opt in or out of allowing apps to request user consent to
    /// access app-related data that can be used for tracking the user or the
    /// device.
    #[doc(alias = "ATTrackingManagerAuthorizationStatusRestricted")]
    pub const Restricted: Self = Self(1);
    /// The value that returns if the user denies authorization to access
    /// app-related data for tracking the user or the device.
    ///
    /// The end user has denied the authorization request to access app-related
    /// data that can be used for tracking the user or the device.
    #[doc(alias = "ATTrackingManagerAuthorizationStatusDenied")]
    pub const Denied: Self = Self(2);
    /// The value that returns if the user authorizes access to app-related data for
    /// tracking the user or the device.
    ///
    /// This setting allows users to opt in or out of allowing apps to request user
    /// consent to access app-related data for tracking the user or the device. End
    /// users can revoke permission at any time through the Allow Apps to Request to
    /// Track privacy setting on the device.
    #[doc(alias = "ATTrackingManagerAuthorizationStatusAuthorized")]
    pub const Authorized: Self = Self(3);
}

unsafe impl Encode for ATTrackingManagerAuthorizationStatus {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for ATTrackingManagerAuthorizationStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A class that provides a tracking authorization request and the tracking
    /// authorization status of the app.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct ATTrackingManager;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for ATTrackingManager {}
);

impl ATTrackingManager {
    extern_methods!(
        /// The authorization status that is current for the calling application.
        ///
        /// If the user has not yet been prompted to approve access, the return value
        /// will either be ``ATTrackingManagerAuthorizationStatusNotDetermined``, or
        /// ``ATTrackingManagerAuthorizationStatusRestricted`` if this value is
        /// managed. Once the user has been prompted, the return value will be either
        /// ``ATTrackingManagerAuthorizationStatusDenied`` or
        /// ``ATTrackingManagerAuthorizationStatusAuthorized``.
        ///
        /// Use the ``ATTrackingManager/trackingAuthorizationStatus`` property to check
        /// authorization status.
        ///
        /// - Returns: Information about your application’s tracking authorization
        /// status. Users are able to grant or deny developers tracking privileges on
        /// a per-app basis. Application developers must call
        /// `requestTrackingAuthorizationWithCompletionHandler:` for the ability to
        /// track users.
        #[unsafe(method(trackingAuthorizationStatus))]
        #[unsafe(method_family = none)]
        pub unsafe fn trackingAuthorizationStatus() -> ATTrackingManagerAuthorizationStatus;

        #[cfg(feature = "block2")]
        /// The request for user authorization to access app-related data.
        ///
        /// The ``ATTrackingManager/requestTrackingAuthorizationWithCompletionHandler:``
        /// is a one-time request to authorize or deny access to app-related data that
        /// can be used for tracking the user or the device. The system remembers the
        /// user’s choice and doesn’t prompt again unless a user uninstalls and then
        /// reinstalls the app on the device.
        ///
        /// Calls to the API only prompt when the application state
        /// is `UIApplicationStateActive`. The authorization prompt doesn’t display if
        /// another permission request is pending user confirmation. Concurrent requests
        /// aren’t preserved by iOS, and calls to the API through an app extension don’t
        /// prompt. Check the ``ATTrackingManager/trackingAuthorizationStatus`` for a
        /// status of
        /// ``ATTrackingManagerAuthorizationStatus/ATTrackingManagerAuthorizationStatusNotDetermined``
        /// to determine if you need to make an additional call.
        ///
        /// The completion handler will be called with the result of the user's
        /// decision for granting or denying permission to use application tracking.
        /// The completion handler will be called immediately if access to request
        /// authorization is restricted.
        ///
        /// - Important: To use
        /// ``ATTrackingManager/requestTrackingAuthorizationWithCompletionHandler:``,
        /// the
        /// <doc
        /// ://com.apple.documentation/documentation/bundleresources/information_property_list/NSUserTrackingUsageDescription>
        /// key must be in the
        /// <doc
        /// ://com.apple.documentation/documentation/bundleresources/information_property_list>.
        #[unsafe(method(requestTrackingAuthorizationWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestTrackingAuthorizationWithCompletionHandler(
            completion: &block2::DynBlock<dyn Fn(ATTrackingManagerAuthorizationStatus)>,
        );

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/apptrackingtransparencyversionnumber?language=objc)
    pub static AppTrackingTransparencyVersionNumber: c_double;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/apptrackingtransparency/apptrackingtransparencyversionstring?language=objc)
    pub static AppTrackingTransparencyVersionString: *mut c_uchar;
}