XAPermission Class Reference

Inherits from NSObject
Declared in XAPermission.h

Overview

The permission API is a set of methods that allow you request permissions from your user, specifically the record permission.

The primary method is requestRecordPermission:, which will request a permission strategy from the server and present it based on the strategie’s requirements.

[XAPermission requestRecordPermission:^(BOOL granted) {
    NSLog(@"%@", granted ? @"Permission Granted" : @"Permission Not Granted");
}];

If this method is called before calling [XAPP startWithAPIKey:withApplicationKey:withAdsDelegate:withUserData:], you will first need to configure the API with useAPIKey:applicationKey:

[XAPermission useAPIKey:apiKey applicationKey:applicationKey];

For more information on permissions see

Request Record Permission

+ requestRecordPermission:

Request record permission, similar to AVAudioSession’s requestRecordPermission_ClassReference/index.html#//apple_ref/occ/instm/AVAudioSession/requestRecordPermission:).

+ (void)requestRecordPermission:(void ( ^ _Nonnull ) ( BOOL granted ))response

Parameters

response

Block that is called when the user either accepts defers, or denies record permission.

Availability

3.13.0

Discussion

Request record permission, similar to AVAudioSession’s requestRecordPermission_ClassReference/index.html#//apple_ref/occ/instm/AVAudioSession/requestRecordPermission:).

Declared In

XAPermission.h

+ fromViewController:requestRecordPermission:

Request record permission. The same as requestRecordPermission: however a specific UIViewController is passed.

+ (void)fromViewController:(nonnull UIViewController *)viewController requestRecordPermission:(void ( ^ _Nonnull ) ( BOOL granted ))response

Parameters

viewController

The view controller the workflow will be displayed over

response

A callback for when the workflow is complete which returns YES if the permission was accepted and NO if it was not granted.

Availability

3.13.0

Discussion

Request record permission. The same as requestRecordPermission: however a specific UIViewController is passed.

This method starts a permissioning workflow that will enage directly with the user, explaining to them the need for record permission and present them a prepermission dialog.

Declared In

XAPermission.h

Configuration

+ useAPIKey:applicationKey:

Set the application credentials required for requesting permission strategies.

+ (void)useAPIKey:(nonnull NSString *)apiKey applicationKey:(nonnull NSString *)aplicationkey

Parameters

apiKey

API key string specific to your publisher

aplicationkey

Application key string specific to the current application

Availability

3.13.0

Discussion

Set the application credentials required for requesting permission strategies.

Use of this method is required if you do not provide the credentials in your app’s plist.

Declared In

XAPermission.h

Testing and Debugging

+ fromViewController:forPermission:presentStrategy:

Present the permission strategy. This method does not go on to request the actual system permission and is used primarily for testing. It is the underlying implementation of requestRecordPermission:.

+ (void)fromViewController:(nonnull UIViewController *)viewController forPermission:(nonnull NSString *)permissionType presentStrategy:(void ( ^ _Nonnull ) ( XAPermissionStatus status , NSError *_Nullable error ))response

Parameters

viewController

The view controller the strategy workflow will be presented from

permissionType

The type of permission to present.

response

A callback providing a status when the workflow is complete

Availability

3.13.0

Discussion

Present the permission strategy. This method does not go on to request the actual system permission and is used primarily for testing. It is the underlying implementation of requestRecordPermission:.

This will retrieve a permission strategy if one isn’t available locally or attempt to present one if one is available.

Declared In

XAPermission.h

+ permissionStatusToString:

Convert the XAPermissionStatus to a human readable string

+ (nullable NSString *)permissionStatusToString:(XAPermissionStatus)status

Parameters

status

Permission status

Return Value

Corresponding string value for the status

Availability

3.13.0

Discussion

Convert the XAPermissionStatus to a human readable string

Declared In

XAPermission.h

+ clearCachedStrategy

Clears the cached strategy.

+ (BOOL)clearCachedStrategy

Return Value

Returns YES if the strategy was successfully cleared out, NO if there was no strategy to clear or

Availability

3.13.0

Discussion

Clears the cached strategy.

When requestRecordPermisison: is called, it checks to see if it has a permission strategy already cached.

Declared In

XAPermission.h

+ clearExcludedStrategies

Clears the cached list of excluded strategies.

+ (BOOL)clearExcludedStrategies

Return Value

Returns YES if the strategy was successfully cleared, NO if there was no excluded list to clear or it was uncessful.

Availability

3.13.0

Discussion

Clears the cached list of excluded strategies.

Excluded strategies are strategies that were deferred by the user and should no longer be presented to the user.

Declared In

XAPermission.h

+ useDevServer

Use the development server. You should not call this.

+ (void)useDevServer

Discussion

Use the development server. You should not call this.

Declared In

XAPermission.h