objc2_tv_services/generated/TVUserManager.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvuseridentifier?language=objc)
11#[deprecated = "User Management capability get-current-user is no longer supported. Please use runs-as-current-user-with-user-independent-keychain and kSecUseUserIndependentKeychain for sharing keychain items across users."]
12pub type TVUserIdentifier = NSString;
13
14extern_class!(
15 /// An object that provides facilities to best handle system users
16 /// as it relates to their preferences like app-specific profiles.
17 ///
18 /// Applications sometimes have their own notion of a "profile", to
19 /// track users' preferences or other state. Those applications can rely on tvOS
20 /// to handle separating each user's data by adopting the "Runs as Current User"
21 /// entitlement, with this entitlement reading and writing data will happen for the
22 /// selected user.
23 ///
24 ///
25 /// Note: When running as the current user each user would have to sign in again to
26 /// the app, to avoid that behavior it is highly recommended that those apps also
27 /// use `kSecUseUserIndependentKeychain` to store their account credentials across
28 /// users.
29 ///
30 /// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvusermanager?language=objc)
31 #[unsafe(super(NSObject))]
32 #[derive(Debug, PartialEq, Eq, Hash)]
33 pub struct TVUserManager;
34);
35
36extern_conformance!(
37 unsafe impl NSObjectProtocol for TVUserManager {}
38);
39
40impl TVUserManager {
41 extern_methods!(
42 /// Indicates if the system recommends that the app saves the user's
43 /// preferences.
44 ///
45 ///
46 /// Apps with the User Management capability "Runs as Current User"
47 /// should remember the user's choices, like which profile they use, that way
48 /// people will immediately see the content they want without any interruptions
49 /// like having to pick their profile again.
50 ///
51 /// You can safely assume that storing the user's preferences is the desirable
52 /// behavior. In some situations though it might not be, and this method represents
53 /// when the system believe it best to continue to, for example, show the profile
54 /// picker.
55 ///
56 /// This property will return `NO` if there is only one Apple TV user, or if your
57 /// app doesn't have the capability of running as the current user.
58 ///
59 ///
60 /// Note: If your app is deployed on tvOS 15 or earlier, you should treat those as
61 /// if this property is returning `NO`.
62 #[unsafe(method(shouldStorePreferencesForCurrentUser))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn shouldStorePreferencesForCurrentUser(&self) -> bool;
65
66 /// Retrieve the identifier for the current system user.
67 ///
68 /// This value may be nil if no value is available to the application. When this is nil or the application has no existing mapping from the user to a preferred profile, the application can put up its profile picker or adopt some other appropriate behavior. For users which are part of the Home this Apple TV is in, this value is the same on all the Apple TVs that are part of that Home.
69 /// This property is KVO-observable, to watch for changes. You will need to hold onto a TVUserManager instance to observe this property on it.
70 #[deprecated = "User Management capability get-current-user is no longer supported. Please use runs-as-current-user-with-user-independent-keychain and kSecUseUserIndependentKeychain for sharing keychain items across users."]
71 #[unsafe(method(currentUserIdentifier))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn currentUserIdentifier(&self) -> Option<Retained<TVUserIdentifier>>;
74
75 /// Tell the system the user identifiers to which the current profile corresponds.
76 ///
77 /// The value should be an NSArray with the system user identifiers that prefer the current profile in the application. An application which is maintaining system user identifer to profile mappings should write a new value to this set whenever the user changes the current profile within the application. The value of this property can be read, but it simply contains the last value stored in it, and starts empty when an application launches.
78 /// This property is KVO-observable, to watch for changes. You will need to hold onto a TVUserManager instance to observe this property on it.
79 #[deprecated = "User Management capability get-current-user is no longer supported. Please use runs-as-current-user-with-user-independent-keychain and kSecUseUserIndependentKeychain for sharing keychain items across users."]
80 #[unsafe(method(userIdentifiersForCurrentProfile))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn userIdentifiersForCurrentProfile(
83 &self,
84 ) -> Retained<NSArray<TVUserIdentifier>>;
85
86 /// Setter for [`userIdentifiersForCurrentProfile`][Self::userIdentifiersForCurrentProfile].
87 ///
88 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
89 #[deprecated = "User Management capability get-current-user is no longer supported. Please use runs-as-current-user-with-user-independent-keychain and kSecUseUserIndependentKeychain for sharing keychain items across users."]
90 #[unsafe(method(setUserIdentifiersForCurrentProfile:))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn setUserIdentifiersForCurrentProfile(
93 &self,
94 user_identifiers_for_current_profile: &NSArray<TVUserIdentifier>,
95 );
96
97 #[cfg(all(feature = "TVAppProfileDescriptor", feature = "block2"))]
98 /// Present a user-to-profile configuration panel to the user.
99 ///
100 /// Parameter `currentSettings`: All the mappings of system user identifiers to their preferred profile string labels that the application currently has. Profile descriptors with no name (or empty string) are ignored, along with the mapping in the dictionary. Profile descriptors which have names that aren't also in the availableProfiles list are ignored, along with the mapping in the dictionary. Ignored mappings will not be present in the resulting newSettings dictionary. It is not required that the profile descriptor values in the dictionary are the exact instances in the availableProfiles list.
101 ///
102 /// Parameter `availableProfiles`: A list of profile descriptors initialized with the third-party in-app profiles currently available in the application, from which the user can choose in the user interface. Profile descriptors with no name (or empty string) are ignored. Duplicate profile descriptors are ignored.
103 ///
104 /// Parameter `completion`: A block to be called when the user interface is dismissed. The dictionary argument to the block will give the new settings as changed by the user. Note that entries in the original settings argument may be missing in the new dictionary, if the user set the preferred profile for a user back to the "no preference" setting. The descriptor objects in the dictionary argument of the completion block come from among the specific instances in the availableProfiles input argument. In other words, the instances in the availableProfiles array are preserved through to the argument to the completion block, and the values of the input existingSettings dictionary are not (unless they happen to be the same objects that appear in the availableProfiles list), but neither are entirely new TVAppProfileDescriptor objects manufactured.
105 ///
106 /// The system will present a panel to the user which allows the user to configure all the preferred profiles for this application for all users on the system. Once the user dismisses the panel, the completion callback will give the new settings, which should be saved by the application. The application should invoke this method from some place in its user interface, perhaps a button in the app's "settings" area.
107 /// The completion block is executed on an arbitrary dispatch queue / thread.
108 /// If invoked from within an extension, no UI will be presented and the dictionary parameter to the callback will be empty.
109 #[deprecated = "User Management capability get-current-user is no longer supported. Please use runs-as-current-user-with-user-independent-keychain and kSecUseUserIndependentKeychain for sharing keychain items across users."]
110 #[unsafe(method(presentProfilePreferencePanelWithCurrentSettings:availableProfiles:completion:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn presentProfilePreferencePanelWithCurrentSettings_availableProfiles_completion(
113 &self,
114 current_settings: &NSDictionary<TVUserIdentifier, TVAppProfileDescriptor>,
115 available_profiles: &NSArray<TVAppProfileDescriptor>,
116 completion: &block2::DynBlock<
117 dyn Fn(NonNull<NSDictionary<TVUserIdentifier, TVAppProfileDescriptor>>),
118 >,
119 );
120
121 #[cfg(all(feature = "TVAppProfileDescriptor", feature = "block2"))]
122 /// Ask the system if a new mapping from the current system user to a user-chosen profile should be created.
123 ///
124 /// Parameter `profile`: A profile descriptor initialized with the third-party in-app profile information. If the profile descriptor has no name or an empty string name, the answer to the completion block will be NO.
125 ///
126 /// Parameter `completion`: A block to be called upon completion of the request. The parameter of the block indicates whether or not the application should create a mapping or skip it.
127 ///
128 /// An application uses this method to confirm with the system that the application should adopt a profile chosen from a profile picker as the preferred profile for that user identifier. The system will usually then ask the user with some user interface what the user wants to do. If the answer is NO, the application should not store the chosen profile as the user's preferred profile. An application should only ask this once per user identifier and profile pair, so even if the answer is NO, the application needs to record that the system has been asked, for that identifier + profile pair.
129 /// The completion block is executed on an arbitrary dispatch queue / thread.
130 /// If invoked from within an extension, no UI will be presented and the result will always be NO.
131 #[deprecated = "User Management capability get-current-user is no longer supported. Please use runs-as-current-user-with-user-independent-keychain and kSecUseUserIndependentKeychain for sharing keychain items across users."]
132 #[unsafe(method(shouldStorePreferenceForCurrentUserToProfile:completion:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn shouldStorePreferenceForCurrentUserToProfile_completion(
135 &self,
136 profile: &TVAppProfileDescriptor,
137 completion: &block2::DynBlock<dyn Fn(Bool)>,
138 );
139 );
140}
141
142/// Methods declared on superclass `NSObject`.
143impl TVUserManager {
144 extern_methods!(
145 #[unsafe(method(init))]
146 #[unsafe(method_family = init)]
147 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
148
149 #[unsafe(method(new))]
150 #[unsafe(method_family = new)]
151 pub unsafe fn new() -> Retained<Self>;
152 );
153}
154
155extern "C" {
156 /// Posted to the default NSNotificationCenter whenever the current system user changes.
157 ///
158 /// The object of the notification is nil. In order to start receiving notification you have to instantiate TVUserManager at least once.
159 ///
160 /// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvusermanagercurrentuseridentifierdidchangenotification?language=objc)
161 #[deprecated = "User Management capability get-current-user is no longer supported. Use the capability runs-as-current-user-with-user-independent-keychain, with it there is no need to be notified of user changes."]
162 pub static TVUserManagerCurrentUserIdentifierDidChangeNotification: &'static NSNotificationName;
163}