CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

App-Notice-IAB 1.1.1

App-Notice-IAB 1.1.1

Maintained by Will Broadhead, Jake ODowd, Jeff Wheeler.



App-Notice SDK for iOS (IAB VERSION)
Installation and Customization

Version: 1.1.1
October 31, 2018

WIP ReadMe

Version License Platform

Features

  • Implied Consent Tracking
  • Explicit Consent Tracking
  • Text Customization and Localization
  • User Tracking Toggling
  • Data Access Requests

Example

This repo comes with two example projects to demonstrate how to use the SDK. The 'Triangle' project is in Swift and Triangle-Objc is written in Objective-C. These are located in the Example folder.

To run the Triangle project, clone the repo, and run pod install from the Example/Triangle directory. If previously installed, run pod update App-Notice-IAB.

Author

Evidon

License

App-Notice is available under the MIT license. See the LICENSE file for more info.

Prerequisites

  • iOS 8.0+
  • Xcode 7.0+
  • A valid App Notice ID from the Evidon Privacy control panel. See your Evidon Customer Success Manager for details.

Installation

App-Notice is available through CocoaPods. To install:

Add the following line to your Podfile, then run 'pod install' and open your xcworkspace file.

pod 'App-Notice-IAB'

If you are using the SDK with an Objective-C project, just add the following line to import the framework in any file that uses it. If you have a Swift project, you'll need to add this line to your bridging header file instead. (See creating a bridging header below for how to do this.)

#import <AppNoticeSDKFramework/AppNoticeSDKFramework.h>

Creating a bridging header for Swift projects

If your project is in Swift and you don't already have a bridging header file, the easiest way to create it is to add a new Objective-C file to your project. Xcode will then ask if you want it to configure an Objective-C briding header. Select "Create Bridging Header", and then you can delete the extra Objective-C file you just created.

SDK Activation

You must activate the SDK before you can use the SDK features. You do so using your activation token.

Note that the SDK tracker list is only downloaded once and stored on the device for each activation token. This means if you make changes to the tracker list after your app is released, you'll need to create a new App Notice with a different activation token. You will need to then update the SDK and re-publish your app before those changes will appear.

Swift

AppNoticeSDK.sharedInstance().activateWithToken("bff0f04910354fb8a042650840056c9d")

Objective-C

[[AppNoticeSDK sharedInstance] activateWithToken:@"bff0f04910354fb8a042650840056c9d"];

Usage

Asking For Consent

There are two types of consent: Implied and Explicit. Implied is the recommended (and simpler) option, but you can choose either one based on which showConsentFlow SDK method you call. To be fully compliant with privacy regulations, you should ask for the user's consent as early as possible after your app launches. And, if you are using explicit, the notice must appear first and prior to firing any tracking technologies.

Call the showConsentFlow (or showExplicitConsentFlow) method from the viewDidAppear method of your main view controller. This way, the SDK can determine whether the dialog needs to be shown or not.

Implied Consent

Implied consent is essentially a disclosure-only option. It informs the user that he is automaticaly giving consent simply by continuing to use the app, but does also accommodate turning individual trackers on/off. As such, it does not include Accept or Decline options, just Continue. It also includes the repeatEvery30Days parameter, which causes the consent dialog to be redisplayed every 30 days if true. If false, the dialog will only appear once per notice ID.

Swift
override func viewDidAppear(animated: Bool) {
  showPrivacyConsentFlow()
    
  super.viewDidAppear(animated)
}

func showPrivacyConsentFlow() {
  AppNoticeSDK.sharedInstance().showConsentFlowWithOnClose({ (result, trackers) in
    // TODO: Handle what you want to do based on whether the user accepted or declined consent.
    // You should also allow or block specific trackers/ads based on the 'trackers' array contents.
  }, presentingViewController:self, repeatEvery30Days:false)
}
Objective-C
- (void)viewDidAppear:(BOOL)animated {
  // show the privacy consent flow (if needed)
  [self showPrivacyConsentFlow];
    
  [super viewDidAppear:animated];
}

- (void)showPrivacyConsentFlow {
  [[AppNoticeSDK sharedInstance] showConsentFlowWithOnClose:^(AppNoticeConsent result, NSDictionary *trackers) {
    // TODO: Handle what you want to do based on whether the user accepted or declined consent.
    // You should also allow or block specific trackers/ads based on the 'trackers' array contents.
  } presentingViewController:self repeatEvery30Days:NO];
}

Explicit Consent

Explicit consent must either be accepted or declined by the user. If consent is accepted, your app may proceed as usual. However, if consent is declined there are a few cases that you'll need to handle:

Swift
override func viewDidAppear(animated: Bool) {
  showPrivacyConsentFlow()
    
  super.viewDidAppear(animated)
}

func showPrivacyConsentFlow() {
  AppNoticeSDK.sharedInstance().showExplicitConsentFlowWithOnClose({ (result, trackers) in
    // TODO: Handle what you want to do based on whether the user accepted or declined consent.
    // You should also allow or block specific trackers/ads based on the 'trackers' array contents.
    }, presentingViewController: self)
}
Objective-C
- (void)viewDidAppear:(BOOL)animated {
  // show the privacy consent flow (if needed)
  [self showPrivacyConsentFlow];
    
  [super viewDidAppear:animated];
}

- (void)showPrivacyConsentFlow {
  [[AppNoticeSDK sharedInstance] showExplicitConsentFlowWithOnClose:^(AppNoticeConsent result, NSDictionary *trackers) {
    // TODO: Handle what you want to do based on whether the user accepted or declined consent.
    // You should also allow or block specific trackers/ads based on the 'trackers' array contents.
  } presentingViewController:self];
}

Tracking Preferences

Users can toggle trackers on or off. To present the tracking preferences screen:

Swift
AppNoticeSDK.sharedInstance().showManagePreferences { () -> Void in
    // TODO: Handle what you want to do after the preferences screen is closed.
            
    // Get the newly updated tracker preferences
    if let updatedTrackers = AppNoticeSDK.sharedInstance().getTrackerPreferences() as? Dictionary<String, NSNumber> {
        // TODO: Do something with the updated trackers
    }
}
Objective-C
[[AppNoticeSDK sharedInstance]showManagePreferences:^{
// TODO: Handle what you want to do after the preferences screen is closed.

//Get the newly updated tracker preferences
NSDictionary *updatedTrackers = [[AppNoticeSDK sharedInstance] getTrackerPreferences];

}];

Localization and Text Customization

The AppNotice SDK can support multiple languages (currently English only, but French, Italian, Dutch, German, Spanish and Portuguese will be available soon). If your app supports localization for a supported language, the AppNotice SDK will also be displayed in that language. To localize your app, you simply need a localization file in your project for each language you support. See Apple's documentation for details on how to add localization to your app.

To customize any of the strings shown in the SDK:

  1. Add a localization file to your project for the desired language (if it doesn't already exist).
  2. Find the key for the string you want to customize. You'll find it in the Localizable.strings file of the SDK's AppNotice.bundle.
  3. Copy the key into Localizable.strings file in your own app for the language you want to customize.
  4. Set the value (not the key) of your newly added string to the text you want to display.

For example, to customize the ghostery_dialog_implicit_message property in English, copy the key from en.lproj in the SDK AppNotice bundle shown here:

Paste it into your Localizable.strings file in your project and enter the desired text as the value:

If you want to apply the same change for other languages, just update the same ghostery_dialog_implicit_message property for the corresponding Localizable.strings file (en.lproj/Localizable.strings for English, de.lproj/Localizable.strings for German, es.lproj/Localizable.strings for Spanish, etc.).

UI Customization

Perhaps you'd like to customize the look and feel of the AppNotice views to match the theme of your app. If all you need to do is change from the default light theme to a dark theme, simply set the appTheme property on AppNoticeSDK:

AppNoticeSDK.sharedInstance().appTheme = AppNoticeThemeDark
[AppNoticeSDK sharedInstance].appTheme = AppNoticeThemeDark;

For more detailed customization, the following AppNoticeSDK UIColor properties are available:

  • mainTextColor: Color of the text within the SDK.
  • backgroundColor: Background color of all views.
  • acceptButtonColor: Tint/background color of the Accept/Continue buttons.
  • acceptButtonTextColor: Text color of the Accept/Continue buttons.
  • declineButtonColor: Color of the Decline buttons.
  • navBarBackgroundColor: Background color of the navigation bar.
  • navBarTitleColor: Color of the center title text of the navigation bar.
  • tintColor: The tint color applies to the checkboxes, the Settings button, and the back/forward buttons in the navigation bar.
  • disabledColor: The color of the disabled checkbox state (used in the essential tab).
  • separatorColor: The color for horizontal and vertical separators as well as the selected color of the preferences table view cells.

Supporting Multiple App Versions

To support multiple versions of your app that each have a different set of trackers, use a unique App Notice configuration in each version of your app. Use the Ghostery control panel (https://my.ghosteryenterprise.com) to create an App Notice configuration for each version of your app that has a different combination of trackers.

After creating an App Notice, make sure to use the correct App Notice ID in your app when you initialize the SDK as shown above.