How to display permission to track in iOS 14.5 and above in Objective-C?

#import <AppTrackingTransparency/AppTrackingTransparency.h>
  1. You need to add an if statement to check if the iOS version is 14 and above.
  2. Use the method requestTrackingAuthorizationWithCompletionHandler: to display permission to track.
    Note: This is permission will only be displayed once to the user during the first time the user has opened the application.
if (@available(iOS 14, *)) {
// Display permission to track
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
switch(status) {
case ATTrackingManagerAuthorizationStatusNotDetermined :
NSLog(@"Unknown consent");
case ATTrackingManagerAuthorizationStatusRestricted :
NSLog(@"Device has an MDM solution applied");
case ATTrackingManagerAuthorizationStatusDenied :
NSLog(@"Denied consent");
case ATTrackingManagerAuthorizationStatusAuthorized :
NSLog(@"Granted consent");
default :
NSLog(@"Unknown");
}
}];
}
  1. The case ATTrackingManagerAuthorizationStatusAuthorized meant the user has authorised the application.
  2. The case ATTrackingManagerAuthorizationStatusRestricted meant the display permission is not shown to the user and also tracking is restricted.
  3. The case ATTrackingManagerAuthorizationStatusDenied meant the user has not authorised the application.
  4. The case ATTrackingManagerAuthorizationStatusNotDetermined meant the application cannot determine the authorisation status for access.

--

--

--

Software Engineer (Android, iOS, Unity) | M.Sc. Computer Science — Technische Universitaet Berlin | Mobile Advertising, Attribution, Monetisation, UA & Analytic

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Objective-C: Case-sensitive in file names in Xcode 12.5 and above

How to use Swift Package Manager

Writing Integration Tests for Your Network Layer Using URLProtocol

smartphone

UICollectionViewCell dynamic height (Swift)

What SwiftUI Means for Flutter

Customizing Property Wrappers in Swift

Bottom Navigation Animation in Jetpack Compose

Objective-C: Does Learning from the fourth edition of the book Objective-C for Absolute Beginners…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akarsh SEGGEMU

Akarsh SEGGEMU

Software Engineer (Android, iOS, Unity) | M.Sc. Computer Science — Technische Universitaet Berlin | Mobile Advertising, Attribution, Monetisation, UA & Analytic

More from Medium

How to resolve the swiping right action when trying to navigate to a previous screen in iOS.

Do you know you can test the Apple Push Notification service (APNs) in Simulator?

What are the components of a URL? Why things should be encoded? What does it look likes in Swift?

Moving your first steps with Siri

Image of Siri’s icon