Appodeal
This commit is contained in:
15
Assets/Plugins/iOS/ConsentManager/ConsentBridge.h
Normal file
15
Assets/Plugins/iOS/ConsentManager/ConsentBridge.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
FOUNDATION_EXPORT const char *GetZone(void);
|
||||
FOUNDATION_EXPORT const char *GetStatus(void);
|
||||
FOUNDATION_EXPORT const char *GetIabString(void);
|
||||
FOUNDATION_EXPORT const char *HasConsentForVendor(const char *bundle);
|
||||
FOUNDATION_EXPORT const char *GetChar(NSString *message);
|
||||
FOUNDATION_EXPORT const char *GetAuthorizationStatus(void);
|
||||
@interface ConsentBridge : NSObject
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
33
Assets/Plugins/iOS/ConsentManager/ConsentBridge.h.meta
Normal file
33
Assets/Plugins/iOS/ConsentManager/ConsentBridge.h.meta
Normal file
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2b010e1b7e814fa989f2fa3694c83bc
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
67
Assets/Plugins/iOS/ConsentManager/ConsentBridge.m
Normal file
67
Assets/Plugins/iOS/ConsentManager/ConsentBridge.m
Normal file
@@ -0,0 +1,67 @@
|
||||
#if defined(__has_include) && __has_include("UnityAppController.h")
|
||||
#import "UnityAppController.h"
|
||||
#else
|
||||
#import "EmptyUnityAppController.h"
|
||||
#endif
|
||||
|
||||
#import "ConsentBridge.h"
|
||||
#import <StackConsentManager/StackConsentManager.h>
|
||||
|
||||
|
||||
const char *GetZone(void) {
|
||||
switch (STKConsentManager.sharedManager.regulation) {
|
||||
case STKConsentRegulationCCPA: return GetChar(@"CCPA"); break;
|
||||
case STKConsentRegulationGDPR: return GetChar(@"GDPR"); break;
|
||||
case STKConsentRegulationNone: return GetChar(@"NONE"); break;
|
||||
case STKConsentRegulationUnknown: return GetChar(@"UNKNOWN"); break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetStatus(void) {
|
||||
switch (STKConsentManager.sharedManager.consentStatus) {
|
||||
case STKConsentStatusUnknown: return GetChar(@"UNKNOWN"); break;
|
||||
case STKConsentStatusPersonalized: return GetChar(@"PERSONALIZED"); break;
|
||||
case STKConsentStatusNonPersonalized: return GetChar(@"NON_PERSONALIZED"); break;
|
||||
case STKConsentStatusPartlyPersonalized: return GetChar(@"PARTLY_PERSONALIZED"); break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetIabString(void) {
|
||||
if(STKConsentManager.sharedManager.iabConsentString == NULL){
|
||||
return GetChar(@"EMPTY");
|
||||
}
|
||||
return GetChar(STKConsentManager.sharedManager.iabConsentString);
|
||||
}
|
||||
|
||||
const char *HasConsentForVendor(const char *bundle) {
|
||||
if (bundle == NULL) {
|
||||
return GetChar(@"UNKNOWN");
|
||||
}
|
||||
|
||||
NSString *bundleString = [[NSString alloc] initWithUTF8String:bundle];
|
||||
STKConsentBool result = [STKConsentManager.sharedManager hasConsentForVendorBundle:bundleString];
|
||||
switch (result) {
|
||||
case STKConsentBoolTrue: return GetChar(@"TRUE"); break;
|
||||
case STKConsentBoolFalse: return GetChar(@"FALSE"); break;
|
||||
case STKConsentBoolUnknown: return GetChar(@"UNKNOWN"); break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetAuthorizationStatus(void) {
|
||||
switch (STKConsentManager.sharedManager.trackingAuthorizationStatus) {
|
||||
case STKTrackingAuthorizationStatusNotDetermined: return GetChar(@"NOT_DETERMINED"); break;
|
||||
case STKTrackingAuthorizationStatusRestricted: return GetChar(@"RESTRICTED"); break;
|
||||
case STKTrackingAuthorizationStatusDenied: return GetChar(@"DENIED"); break;
|
||||
case STKTrackingAuthorizationStatusAuthorized: return GetChar(@"AUTHORIZED"); break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetChar(NSString *message){
|
||||
const char *cString = [message UTF8String];
|
||||
char *cStringCopy = calloc([message length]+1, 1);
|
||||
return strncpy(cStringCopy, cString, [message length]);
|
||||
}
|
||||
|
||||
@implementation ConsentBridge
|
||||
|
||||
@end
|
||||
33
Assets/Plugins/iOS/ConsentManager/ConsentBridge.m.meta
Normal file
33
Assets/Plugins/iOS/ConsentManager/ConsentBridge.m.meta
Normal file
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b57bbcf4fefb4f1e82263be57ce88a1
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/Plugins/iOS/ConsentManager/ConsentForm.h
Normal file
30
Assets/Plugins/iOS/ConsentManager/ConsentForm.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ConsentManagerErrorBridge.h"
|
||||
#import "ConsentBridge.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class ConsentForm;
|
||||
|
||||
typedef void (ConsentFormCallback)(void);
|
||||
typedef void (ConsentFormCallbackError)(ConsentManagerErrorBridge *error);
|
||||
typedef void (ConsentFormCallbackClosed)(ConsentBridge *consent);
|
||||
|
||||
FOUNDATION_EXPORT ConsentForm *GetConsentForm(void);
|
||||
FOUNDATION_EXPORT void WithListener(ConsentFormCallback onConsentFormLoaded,
|
||||
ConsentFormCallbackError onConsentFormError,
|
||||
ConsentFormCallback onConsentFormOpened,
|
||||
ConsentFormCallbackClosed onConsentFormClosed);
|
||||
|
||||
FOUNDATION_EXPORT ConsentForm *GetConsentForm(void);
|
||||
FOUNDATION_EXPORT void Load(void);
|
||||
FOUNDATION_EXPORT void Show(void);
|
||||
FOUNDATION_EXPORT bool IsLoaded(void);
|
||||
FOUNDATION_EXPORT bool IsShowing(void);
|
||||
|
||||
|
||||
@interface ConsentForm : NSObject
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
33
Assets/Plugins/iOS/ConsentManager/ConsentForm.h.meta
Normal file
33
Assets/Plugins/iOS/ConsentManager/ConsentForm.h.meta
Normal file
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c1d088dd71844da3a9729e1f41eafb5
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
145
Assets/Plugins/iOS/ConsentManager/ConsentForm.m
Normal file
145
Assets/Plugins/iOS/ConsentManager/ConsentForm.m
Normal file
@@ -0,0 +1,145 @@
|
||||
#if defined(__has_include) && __has_include("UnityAppController.h")
|
||||
#import "UnityAppController.h"
|
||||
#else
|
||||
#import "EmptyUnityAppController.h"
|
||||
#endif
|
||||
|
||||
#import "ConsentForm.h"
|
||||
#import "ConsentManagerBridge.h"
|
||||
|
||||
#import <StackConsentManager/StackConsentManager.h>
|
||||
|
||||
#pragma mark - ConsentForm
|
||||
|
||||
@interface ConsentForm () <STKConsentManagerDisplayDelegate>
|
||||
|
||||
@property (nonatomic, assign) ConsentFormCallback *onConsentFormLoaded;
|
||||
@property (nonatomic, assign) ConsentFormCallbackError *onConsentFormError;
|
||||
@property (nonatomic, assign) ConsentFormCallback *onConsentFormOpened;
|
||||
@property (nonatomic, assign) ConsentFormCallbackClosed *onConsentFormClosed;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation ConsentForm
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static ConsentForm *_form;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_form = [ConsentForm new];
|
||||
});
|
||||
return _form;
|
||||
}
|
||||
|
||||
- (BOOL)isReady {
|
||||
return STKConsentManager.sharedManager.consentDialogReady;
|
||||
}
|
||||
|
||||
- (BOOL)isPresenting {
|
||||
return STKConsentManager.sharedManager.isConsentDialogPresenting;
|
||||
}
|
||||
|
||||
- (void)loadConsentForm {
|
||||
[STKConsentManager.sharedManager loadConsentDialog:^(NSError *error) {
|
||||
if (error) {
|
||||
if (self.onConsentFormError != NULL) {
|
||||
SetCurrentError(error);
|
||||
self.onConsentFormError(GetCurrentErrorBridge());
|
||||
}
|
||||
} else {
|
||||
if (self.onConsentFormLoaded != NULL) {
|
||||
self.onConsentFormLoaded();
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showDialog {
|
||||
UIViewController *rootViewController;
|
||||
if ([UIApplication.sharedApplication.delegate respondsToSelector:@selector(rootViewController)]) {
|
||||
rootViewController = [UIApplication.sharedApplication.delegate performSelector:@selector(rootViewController)];
|
||||
} else {
|
||||
UIWindow *keyWindow;
|
||||
if (@available(iOS 13, *)) {
|
||||
NSPredicate *sceneFilter = [NSPredicate predicateWithBlock:^BOOL(UIScene *scene, NSDictionary<NSString *,id> *bindings) {
|
||||
return [scene isKindOfClass:UIWindowScene.class] && scene.activationState == UISceneActivationStateForegroundActive;
|
||||
}];
|
||||
NSPredicate *windowFilter = [NSPredicate predicateWithBlock:^BOOL(UIWindow *window, NSDictionary<NSString *,id> *bindings) {
|
||||
return [window isKeyWindow];
|
||||
}];
|
||||
|
||||
NSArray <UIWindowScene *> *scenes = (NSArray <UIWindowScene *> *)[[UIApplication.sharedApplication.connectedScenes filteredSetUsingPredicate: sceneFilter] allObjects];
|
||||
NSArray <UIWindow *> *windows = scenes.firstObject.windows;
|
||||
keyWindow = [[windows filteredArrayUsingPredicate:windowFilter] firstObject];
|
||||
} else {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
keyWindow = UIApplication.sharedApplication.keyWindow;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
rootViewController = keyWindow.rootViewController;
|
||||
while (rootViewController.presentedViewController != nil) {
|
||||
rootViewController = rootViewController.presentedViewController;
|
||||
}
|
||||
}
|
||||
|
||||
[STKConsentManager.sharedManager showConsentDialogFromRootViewController:rootViewController
|
||||
delegate:self];
|
||||
}
|
||||
|
||||
#pragma mark - STKConsentManagerDisplayDelegate
|
||||
|
||||
- (void)consentManager:(STKConsentManager *)consentManager didFailToPresent:(NSError *)error {
|
||||
if (self.onConsentFormError != NULL) {
|
||||
SetCurrentError(error);
|
||||
self.onConsentFormError(GetCurrentErrorBridge());
|
||||
}
|
||||
}
|
||||
|
||||
- (void)consentManagerDidDismissDialog:(STKConsentManager *)consentManager {
|
||||
if (self.onConsentFormClosed != NULL) {
|
||||
self.onConsentFormClosed(GetConsent());
|
||||
}
|
||||
}
|
||||
|
||||
- (void)consentManagerWillShowDialog:(STKConsentManager *)consentManager {
|
||||
if (self.onConsentFormOpened != NULL) {
|
||||
self.onConsentFormOpened();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - Static API
|
||||
|
||||
void WithListener(ConsentFormCallback onConsentFormLoaded,
|
||||
ConsentFormCallbackError onConsentFormError,
|
||||
ConsentFormCallback onConsentFormOpened,
|
||||
ConsentFormCallbackClosed onConsentFormClosed) {
|
||||
|
||||
ConsentForm.sharedInstance.onConsentFormLoaded = onConsentFormLoaded;
|
||||
ConsentForm.sharedInstance.onConsentFormError = onConsentFormError;
|
||||
ConsentForm.sharedInstance.onConsentFormOpened = onConsentFormOpened;
|
||||
ConsentForm.sharedInstance.onConsentFormClosed = onConsentFormClosed;
|
||||
}
|
||||
|
||||
ConsentForm *GetConsentForm(void) {
|
||||
return [ConsentForm sharedInstance];
|
||||
}
|
||||
|
||||
void Load(void) {
|
||||
[ConsentForm.sharedInstance loadConsentForm];
|
||||
}
|
||||
|
||||
void Show(void) {
|
||||
[ConsentForm.sharedInstance showDialog];
|
||||
}
|
||||
|
||||
bool IsLoaded(void) {
|
||||
return [ConsentForm.sharedInstance isReady];
|
||||
}
|
||||
|
||||
bool IsShowing(void) {
|
||||
return [ConsentForm.sharedInstance isPresenting];
|
||||
}
|
||||
33
Assets/Plugins/iOS/ConsentManager/ConsentForm.m.meta
Normal file
33
Assets/Plugins/iOS/ConsentManager/ConsentForm.m.meta
Normal file
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4271754b419d46bcaa2df60d94e4b9e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
Assets/Plugins/iOS/ConsentManager/ConsentManager.h
Normal file
7
Assets/Plugins/iOS/ConsentManager/ConsentManager.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for ConsentManager.
|
||||
FOUNDATION_EXPORT double ConsentManagerVersionNumber;
|
||||
|
||||
//! Project version string for ConsentManager.
|
||||
FOUNDATION_EXPORT const unsigned char ConsentManagerVersionString[];
|
||||
33
Assets/Plugins/iOS/ConsentManager/ConsentManager.h.meta
Normal file
33
Assets/Plugins/iOS/ConsentManager/ConsentManager.h.meta
Normal file
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5056fea578eac481e93819435f0a04c5
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/Plugins/iOS/ConsentManager/ConsentManagerBridge.h
Normal file
32
Assets/Plugins/iOS/ConsentManager/ConsentManagerBridge.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ConsentManagerErrorBridge.h"
|
||||
#import "ConsentBridge.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void (ConsentInfoUpdatedCallback)(ConsentBridge *consent);
|
||||
typedef void (ConsentInfoUpdatedFailedCallback)(ConsentManagerErrorBridge *error);
|
||||
|
||||
FOUNDATION_EXPORT void RequestConsentInfoUpdate(const char *appodealAppKey,
|
||||
ConsentInfoUpdatedCallback onConsentInfoUpdated,
|
||||
ConsentInfoUpdatedFailedCallback onFailedToUpdateConsentInfo);
|
||||
|
||||
FOUNDATION_EXPORT id GetConsentManager(void);
|
||||
FOUNDATION_EXPORT id GetCustomVendor(const char *bundle);
|
||||
FOUNDATION_EXPORT ConsentBridge *GetConsent(void);
|
||||
FOUNDATION_EXPORT const char *GetConstChar(NSString *message);
|
||||
|
||||
FOUNDATION_EXPORT const char *GetStorage(void);
|
||||
FOUNDATION_EXPORT const char *ShouldShowConsentDialog(void);
|
||||
FOUNDATION_EXPORT const char *GetConsentZone(void);
|
||||
FOUNDATION_EXPORT const char *GetConsentStatus(void);
|
||||
FOUNDATION_EXPORT const char *GetIabConsentString(void);
|
||||
|
||||
FOUNDATION_EXPORT void SetStorage(const char *storage);
|
||||
FOUNDATION_EXPORT void SetCustomVendor(id customVendor);
|
||||
|
||||
FOUNDATION_EXPORT void SetCurrentError(NSError *error);
|
||||
FOUNDATION_EXPORT ConsentManagerErrorBridge *GetCurrentErrorBridge(void);
|
||||
FOUNDATION_EXPORT void DisableAppTrackingTransparencyRequest();
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff9c146c14e164271a4ec736b94ed3cb
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
150
Assets/Plugins/iOS/ConsentManager/ConsentManagerBridge.m
Normal file
150
Assets/Plugins/iOS/ConsentManager/ConsentManagerBridge.m
Normal file
@@ -0,0 +1,150 @@
|
||||
#if defined(__has_include) && __has_include("UnityAppController.h")
|
||||
#import "UnityAppController.h"
|
||||
#else
|
||||
#import "EmptyUnityAppController.h"
|
||||
#endif
|
||||
|
||||
#import "ConsentManagerBridge.h"
|
||||
#import "ConsentManagerErrorBridge.h"
|
||||
#import "ConsentBridge.h"
|
||||
#import "VendorBridge.h"
|
||||
|
||||
#import <StackConsentManager/StackConsentManager.h>
|
||||
|
||||
#pragma mark - Declarations
|
||||
|
||||
ConsentManagerErrorBridge *gCurrentError;
|
||||
ConsentBridge *gConsent;
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
id GetConsentManager(void) {
|
||||
return STKConsentManager.sharedManager;
|
||||
}
|
||||
|
||||
id GetCustomVendor(const char *bundle) {
|
||||
if (bundle == NULL) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *bundleString = [[NSString alloc] initWithUTF8String:bundle];
|
||||
return [VendorBridge.sharedVendorBridge.bundle isEqualToString:bundleString] ? VendorBridge.sharedVendorBridge : nil;
|
||||
}
|
||||
|
||||
void SetCurrentError(NSError *error) {
|
||||
gCurrentError = [[ConsentManagerErrorBridge alloc] initWithCode:error.code
|
||||
reason:error.localizedFailureReason ?: @"unknown error"];
|
||||
}
|
||||
|
||||
ConsentManagerErrorBridge *GetCurrentErrorBridge(void) {
|
||||
return gCurrentError;
|
||||
}
|
||||
|
||||
const char *GetStorage(void) {
|
||||
switch (STKConsentManager.sharedManager.storage) {
|
||||
case STKConsentDialogStorageNone:
|
||||
return GetConstChar(@"NONE");
|
||||
break;
|
||||
case STKConsentDialogStorageUserDefaults:
|
||||
return GetConstChar(@"SHARED_PREFERENCE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetConstChar(NSString *message){
|
||||
const char *cString = [message UTF8String];
|
||||
char *cStringCopy = calloc([message length]+1, 1);
|
||||
return strncpy(cStringCopy, cString, [message length]);
|
||||
}
|
||||
|
||||
const char *ShouldShowConsentDialog(void) {
|
||||
switch (STKConsentManager.sharedManager.shouldShowConsentDialog) {
|
||||
case STKConsentBoolTrue: return GetConstChar(@"TRUE"); break;
|
||||
case STKConsentBoolFalse: return GetConstChar(@"FALSE"); break;
|
||||
case STKConsentBoolUnknown: return GetConstChar(@"UNKNOWN"); break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetConsentZone(void) {
|
||||
switch (STKConsentManager.sharedManager.regulation) {
|
||||
case STKConsentRegulationCCPA: return GetConstChar(@"CCPA"); break;
|
||||
case STKConsentRegulationGDPR: return GetConstChar(@"GDPR"); break;
|
||||
case STKConsentRegulationNone: return GetConstChar(@"NONE"); break;
|
||||
case STKConsentRegulationUnknown: return GetConstChar(@"UNKNOWN"); break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetConsentStatus(void) {
|
||||
switch (STKConsentManager.sharedManager.consentStatus) {
|
||||
case STKConsentStatusUnknown: return GetConstChar(@"UNKNOWN"); break;
|
||||
case STKConsentStatusPersonalized: return GetConstChar(@"PERSONALIZED"); break;
|
||||
case STKConsentStatusNonPersonalized: return GetConstChar(@"NON_PERSONALIZED"); break;
|
||||
case STKConsentStatusPartlyPersonalized: return GetConstChar(@"PARTLY_PERSONALIZED"); break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetIabConsentString() {
|
||||
if (STKConsentManager.sharedManager.iabConsentString == NULL) {
|
||||
return GetConstChar(@"EMPTY");
|
||||
}
|
||||
return GetConstChar(STKConsentManager.sharedManager.iabConsentString);
|
||||
}
|
||||
|
||||
id GetConsent(void) {
|
||||
if (!gConsent) {
|
||||
gConsent = [ConsentBridge new];
|
||||
}
|
||||
return gConsent;
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
void SetCustomVendor(id customVendor) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void SetStorage(const char *storage) {
|
||||
if (storage == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *storageString = [[NSString alloc] initWithUTF8String:storage];
|
||||
if ([storageString isEqualToString: @"SHARED_PREFERENCE"]) {
|
||||
STKConsentManager.sharedManager.storage = STKConsentDialogStorageUserDefaults;
|
||||
} else {
|
||||
STKConsentManager.sharedManager.storage = STKConsentDialogStorageNone;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Synchronisation
|
||||
|
||||
void RequestConsentInfoUpdate(const char *appodealAppKey,
|
||||
ConsentInfoUpdatedCallback onConsentInfoUpdated,
|
||||
ConsentInfoUpdatedFailedCallback onFailedToUpdateConsentInfo) {
|
||||
if (appodealAppKey == NULL) {
|
||||
gCurrentError = [[ConsentManagerErrorBridge alloc] initWithCode:0
|
||||
reason:@"Appodeal key can't be null"];
|
||||
onFailedToUpdateConsentInfo(gCurrentError);
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *key = [[NSString alloc] initWithUTF8String:appodealAppKey];
|
||||
|
||||
[VendorBridge.sharedVendorBridge registerCustomVendor];
|
||||
[STKConsentManager.sharedManager synchronizeWithAppKey:key
|
||||
completion:^(NSError *error) {
|
||||
if (error) {
|
||||
SetCurrentError(error);
|
||||
onFailedToUpdateConsentInfo(gCurrentError);
|
||||
} else {
|
||||
if (!gConsent) {
|
||||
gConsent = [ConsentBridge new];
|
||||
}
|
||||
onConsentInfoUpdated(gConsent);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
void DisableAppTrackingTransparencyRequest(){
|
||||
[STKConsentManager.sharedManager disableAppTrackingTransparencyRequest];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd7e4df2e8145487fbea97bb020a48d0
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class ConsentManagerErrorBridge;
|
||||
|
||||
FOUNDATION_EXPORT ConsentManagerErrorBridge *GetConsentManagerException(void);
|
||||
FOUNDATION_EXPORT const char *GetReason(void);
|
||||
FOUNDATION_EXPORT int GetCode(void);
|
||||
|
||||
@interface ConsentManagerErrorBridge : NSObject
|
||||
|
||||
- (instancetype)initWithCode:(NSInteger)code reason:(NSString *)reason;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81c7d5dd3d0834509bd638f04c21dc1a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#if defined(__has_include) && __has_include("UnityAppController.h")
|
||||
#import "UnityAppController.h"
|
||||
#else
|
||||
#import "EmptyUnityAppController.h"
|
||||
#endif
|
||||
|
||||
#import "ConsentManagerErrorBridge.h"
|
||||
#import "ConsentManagerBridge.h"
|
||||
|
||||
|
||||
@interface ConsentManagerErrorBridge ()
|
||||
|
||||
@property (nonatomic, copy) NSString *reason;
|
||||
@property (nonatomic, assign) NSInteger code;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ConsentManagerErrorBridge
|
||||
|
||||
- (instancetype)initWithCode:(NSInteger)code
|
||||
reason:(NSString *)reason {
|
||||
if (self = [super init]) {
|
||||
self.reason = reason;
|
||||
self.code = code;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
ConsentManagerErrorBridge *GetConsentManagerException(void) {
|
||||
return GetCurrentErrorBridge();
|
||||
|
||||
}
|
||||
|
||||
const char *GetReason() {
|
||||
const char *cString = GetCurrentErrorBridge().reason.UTF8String;
|
||||
char *cStringCopy = calloc([GetCurrentErrorBridge().reason length]+1, 1);
|
||||
return strncpy(cStringCopy, cString, [GetCurrentErrorBridge().reason length]);
|
||||
}
|
||||
|
||||
int GetCode() {
|
||||
return (int)GetCurrentErrorBridge().code;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ad9486a69d4347c3bbe72b635e6b785
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Plugins/iOS/ConsentManager/VendorBridge.h
Normal file
33
Assets/Plugins/iOS/ConsentManager/VendorBridge.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class VendorBridge;
|
||||
|
||||
FOUNDATION_EXPORT VendorBridge *GetVendor(const char *appName, const char *appBundle, const char *appURL);
|
||||
FOUNDATION_EXPORT const char *VendorGetName(void);
|
||||
FOUNDATION_EXPORT const char *VendorGetBundle(void);
|
||||
FOUNDATION_EXPORT const char *VendorGetPolicyUrl(void);
|
||||
FOUNDATION_EXPORT const char *VendorGetPurposeIds(void);
|
||||
FOUNDATION_EXPORT const char *VendorGetFeatureIds(void);
|
||||
FOUNDATION_EXPORT const char *VendorGetLegitimateInterestPurposeIds(void);
|
||||
FOUNDATION_EXPORT const char *GetConChar(NSString *message);
|
||||
FOUNDATION_EXPORT NSArray <NSNumber *> *ArrayFromCommaSeparatedString(NSString *string);
|
||||
FOUNDATION_EXPORT NSString *CommaSeparatedStringFromArray(NSArray <NSNumber *> *array);
|
||||
FOUNDATION_EXPORT NSArray <NSNumber *> *ArrayFromCommaSeparatedString(NSString *string);
|
||||
|
||||
FOUNDATION_EXPORT void SetPurposeIds(const char *purposeIds);
|
||||
FOUNDATION_EXPORT void SetFeatureIds(const char *featureIds);
|
||||
FOUNDATION_EXPORT void SetLegitimateInterestPurposeIds(const char *legitimateInterestPurposeIds);
|
||||
|
||||
|
||||
@interface VendorBridge : NSObject
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *bundle;
|
||||
|
||||
+ (instancetype)sharedVendorBridge;
|
||||
- (void)registerCustomVendor;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
33
Assets/Plugins/iOS/ConsentManager/VendorBridge.h.meta
Normal file
33
Assets/Plugins/iOS/ConsentManager/VendorBridge.h.meta
Normal file
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c9d76d1bbe5a47e2a1412f6ac1c2914
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/Plugins/iOS/ConsentManager/VendorBridge.m
Normal file
132
Assets/Plugins/iOS/ConsentManager/VendorBridge.m
Normal file
@@ -0,0 +1,132 @@
|
||||
#if defined(__has_include) && __has_include("UnityAppController.h")
|
||||
#import "UnityAppController.h"
|
||||
#else
|
||||
#import "EmptyUnityAppController.h"
|
||||
#endif
|
||||
|
||||
#import "VendorBridge.h"
|
||||
#import <StackConsentManager/StackConsentManager.h>
|
||||
|
||||
|
||||
@interface VendorBridge ()
|
||||
|
||||
@property (nonatomic, copy) NSString *name;
|
||||
@property (nonatomic, copy) NSString *bundle;
|
||||
@property (nonatomic, copy) NSURL *URL;
|
||||
@property (nonatomic, copy) NSArray <NSNumber *> *featuresIds;
|
||||
@property (nonatomic, copy) NSArray <NSNumber *> *legIntPurposeIds;
|
||||
@property (nonatomic, copy) NSArray <NSNumber *> *purposesIds;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation VendorBridge
|
||||
|
||||
NSString *appName_;
|
||||
NSString *appBundle_;
|
||||
NSURL *appURL_;
|
||||
|
||||
+ (instancetype)sharedVendorBridge {
|
||||
static VendorBridge *_bridge;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_bridge = [VendorBridge new];
|
||||
_bridge.name = appName_;
|
||||
_bridge.bundle = appBundle_;
|
||||
_bridge.URL = appURL_;
|
||||
});
|
||||
return _bridge;
|
||||
}
|
||||
|
||||
- (void)registerCustomVendor {
|
||||
if (self.bundle && self.URL) {
|
||||
[STKConsentManager.sharedManager registerCustomVendor:^(STKVendorBuilder *builder) {
|
||||
builder.appendName(appName_);
|
||||
builder.appendBundle(appBundle_);
|
||||
builder.appendPolicyURL(appURL_);
|
||||
builder.appendFeaturesIds(self.featuresIds);
|
||||
builder.appendLegIntPurposeIds(self.featuresIds);
|
||||
builder.appendPurposesIds(self.purposesIds);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
VendorBridge *GetVendor(const char *appName, const char *appBundle, const char *appURL) {
|
||||
appName_ = [[NSString alloc] initWithUTF8String:appName];
|
||||
appBundle_ = [[NSString alloc] initWithUTF8String:appBundle];
|
||||
appURL_ = [NSURL URLWithString:[[[NSString alloc] initWithUTF8String:appURL] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
|
||||
return [VendorBridge sharedVendorBridge];
|
||||
}
|
||||
|
||||
const char *VendorGetName(void) {
|
||||
const char *cString = VendorBridge.sharedVendorBridge.name.UTF8String;
|
||||
char *cStringCopy = calloc([VendorBridge.sharedVendorBridge.name length]+1, 1);
|
||||
return strncpy(cStringCopy, cString, [VendorBridge.sharedVendorBridge.name length]);
|
||||
}
|
||||
|
||||
const char *VendorGetBundle(void) {
|
||||
const char *cString = VendorBridge.sharedVendorBridge.bundle.UTF8String;
|
||||
char *cStringCopy = calloc([VendorBridge.sharedVendorBridge.bundle length]+1, 1);
|
||||
return strncpy(cStringCopy, cString, [VendorBridge.sharedVendorBridge.bundle length]);
|
||||
}
|
||||
|
||||
const char *VendorGetPolicyUrl(void) {
|
||||
const char *cString = VendorBridge.sharedVendorBridge.URL.absoluteString.UTF8String;
|
||||
char *cStringCopy = calloc([VendorBridge.sharedVendorBridge.URL.absoluteString length]+1, 1);
|
||||
return strncpy(cStringCopy, cString, [VendorBridge.sharedVendorBridge.URL.absoluteString length]);
|
||||
}
|
||||
|
||||
const char *VendorGetPurposeIds(void) {
|
||||
int *purposeIds = malloc(VendorBridge.sharedVendorBridge.purposesIds.count);
|
||||
for (int idx = 0; idx < VendorBridge.sharedVendorBridge.purposesIds.count; idx++) {
|
||||
purposeIds[idx] = VendorBridge.sharedVendorBridge.purposesIds[idx].intValue;
|
||||
}
|
||||
return GetConChar(CommaSeparatedStringFromArray(VendorBridge.sharedVendorBridge.purposesIds));
|
||||
}
|
||||
|
||||
const char *VendorGetFeatureIds(void) {
|
||||
return GetConChar(CommaSeparatedStringFromArray(VendorBridge.sharedVendorBridge.featuresIds));
|
||||
}
|
||||
|
||||
const char *VendorGetLegitimateInterestPurposeIds(void) {
|
||||
return GetConChar(CommaSeparatedStringFromArray(VendorBridge.sharedVendorBridge.legIntPurposeIds));
|
||||
}
|
||||
|
||||
void SetPurposeIds(const char *purposeIds) {
|
||||
VendorBridge.sharedVendorBridge.purposesIds = ArrayFromCommaSeparatedString([[NSString alloc] initWithUTF8String:purposeIds]);;
|
||||
}
|
||||
|
||||
void SetFeatureIds(const char *featureIds) {
|
||||
VendorBridge.sharedVendorBridge.featuresIds = ArrayFromCommaSeparatedString([[NSString alloc] initWithUTF8String:featureIds]);
|
||||
}
|
||||
|
||||
void SetLegitimateInterestPurposeIds(const char *legitimateInterestPurposeIds) {
|
||||
VendorBridge.sharedVendorBridge.legIntPurposeIds = ArrayFromCommaSeparatedString([[NSString alloc] initWithUTF8String:legitimateInterestPurposeIds]);
|
||||
}
|
||||
|
||||
const char *GetConChar(NSString *message) {
|
||||
const char *cString = [message UTF8String];
|
||||
char *cStringCopy = calloc([message length]+1, 1);
|
||||
return strncpy(cStringCopy, cString, [message length]);
|
||||
}
|
||||
|
||||
NSArray <NSNumber *> *ArrayFromCommaSeparatedString(NSString *string) {
|
||||
NSArray <NSString *> *array = [string componentsSeparatedByString:@","];
|
||||
NSMutableArray <NSNumber *> *result = [NSMutableArray arrayWithCapacity:array.count];
|
||||
[array enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
|
||||
NSInteger integerValue = [obj integerValue];
|
||||
[result addObject:@(integerValue)];
|
||||
}];
|
||||
return result;
|
||||
}
|
||||
|
||||
NSString *CommaSeparatedStringFromArray(NSArray <NSNumber *> *array) {
|
||||
NSMutableArray <NSString *> *stringArray = [NSMutableArray arrayWithCapacity:array.count];
|
||||
[array enumerateObjectsUsingBlock:^(NSNumber *obj, NSUInteger idx, BOOL *stop) {
|
||||
[stringArray addObject:obj.stringValue];
|
||||
}];
|
||||
NSString *result = [stringArray componentsJoinedByString:@","];
|
||||
return result;
|
||||
}
|
||||
33
Assets/Plugins/iOS/ConsentManager/VendorBridge.m.meta
Normal file
33
Assets/Plugins/iOS/ConsentManager/VendorBridge.m.meta
Normal file
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ca11f2df7f2e440e8151916f7203831
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user