-
Notifications
You must be signed in to change notification settings - Fork 16
Installing on Obj C project without CocoaPods
André Herculano edited this page Jun 7, 2019
·
3 revisions
- Clone ConsentViewController's repo.
- Clone Reachability's repo
- Copy the file
Sources/Reachability.swift
from the Reachability's folder into your project. If you don't have one yet, XCode will prompt you about creating a bridging header. Click onCreate Bridging Header
. - Copy the
ConsentViewController
folder from theConsentViewController
repo to your project. Make sure to selectAdded folders: Create Groups
like shown in the picture below. - Go to
ConsentViewController/Classes/ConsentViewController.swift
file and delete theimport Reachability
statement. - Finally, on your
ViewController.m
file,#import "YourProjectsProductName-Swift.h"
- You may now use
ConsentViewController
// ViewController.m
#import "ViewController.h"
#import "ObjCSDKSample-Swift.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
ConsentViewController *cvc = [[ConsentViewController alloc] initWithAccountId:22 siteName:@"mobile.demo" stagingCampaign:false andReturnError:nil];
[cvc setTargetingParamString:@"MyPrivacyManager" value:@"true"];
[cvc setOnMessageReady:^(ConsentViewController * consentSDK) {
[self presentViewController:consentSDK animated:false completion:NULL];
}];
[cvc setOnInteractionComplete:^(ConsentViewController * consentSDK) {
[consentSDK getCustomPurposeConsentsWithCompletionHandler:^(NSArray<PurposeConsent *>* purposeConsents) {
NSLog(@"User has given consent to the purposes: %@", purposeConsents);
}];
[consentSDK dismissViewControllerAnimated:false completion:NULL];
}];
[cvc loadMessage];
}
@end
- If your project is a framework itself, you'll need to
#import "YourProductsName/YourProductsName-Swift.h"
(instead of#import "YourProductsName-Swift.h"
). - If you're not able to import the header mentioned above, make sure your Target's Product Name is defined. Try setting it to the name of your Project.
- Some people had to set the option
Define Modules > YES
as well. - If your project's name have spaces in it, substitute them by underscores when importing the header file like
#import "My_Project-Swift.h"