Skip to content
Permalink
Browse files

Release 1.1.0 (#6)

- add Settings.bundle integration examples
- add ContentsTouched notification
  • Loading branch information...
pavel-kroh-smartlook committed Mar 7, 2019
1 parent 813335b commit 57642031acc50e640aec9d4b2cf3400b93a9158e
No changes.
@@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
3313512F222E8D55004BE5AE /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 3313512E222E8D55004BE5AE /* Settings.bundle */; };
337E624F22173CAB00EBAB60 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 337E624E22173CAB00EBAB60 /* AppDelegate.m */; };
337E625222173CAB00EBAB60 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 337E625122173CAB00EBAB60 /* ViewController.m */; };
337E625522173CAB00EBAB60 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 337E625322173CAB00EBAB60 /* Main.storyboard */; };
@@ -33,6 +34,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
3313512E222E8D55004BE5AE /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Settings.bundle; path = ConsentsDemo/Settings.bundle; sourceTree = "<group>"; };
337E624A22173CAB00EBAB60 /* Consents Demo ObjC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Consents Demo ObjC.app"; sourceTree = BUILT_PRODUCTS_DIR; };
337E624D22173CAB00EBAB60 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
337E624E22173CAB00EBAB60 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -62,6 +64,7 @@
337E624122173CAB00EBAB60 = {
isa = PBXGroup;
children = (
3313512E222E8D55004BE5AE /* Settings.bundle */,
33C27E5F221C0B710026F090 /* SmartlookConsentSDK.framework */,
337E624C22173CAB00EBAB60 /* ConsentsDemo */,
337E624B22173CAB00EBAB60 /* Products */,
@@ -154,6 +157,7 @@
files = (
337E625A22173CAC00EBAB60 /* LaunchScreen.storyboard in Resources */,
338579EE221AE740006861C1 /* Localizable.strings in Resources */,
3313512F222E8D55004BE5AE /* Settings.bundle in Resources */,
337E625722173CAC00EBAB60 /* Assets.xcassets in Resources */,
337E625522173CAB00EBAB60 /* Main.storyboard in Resources */,
);
@@ -7,16 +7,36 @@
//

#import "AppDelegate.h"
#import <SmartlookConsentSDK/SmartlookConsentSDK.h>

@interface AppDelegate ()

@end

@implementation AppDelegate

/** This method is to be invoked any time the app starts to check if the consets are provided
namely in:
- `application:didFinishWithLaunchingOptions` for the fresh start
- `application:WillEnterForeground` for app woken up from background (where possibly the consent setting could be changed in system sessings)
*/
-(void)checkConsentStates {
NSMutableArray *consentsSettingsDefaults = [NSMutableArray new];
[consentsSettingsDefaults addObjectsFromArray:@[SLCConsentPrivacy, @(SLCConsentStateProvided)]];
[consentsSettingsDefaults addObjectsFromArray:@[SLCConsentAnalytics, @(SLCConsentStateNotProvided)]];

[SmartlookConsentSDK checkWith:consentsSettingsDefaults callback:^{
if ([SmartlookConsentSDK consentStateFor:SLCConsentAnalytics] == SLCConsentStateProvided) {
// start analytics tools
};
}];

}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Override point for customization after application launch;
[self checkConsentStates];
return YES;
}

@@ -35,6 +55,7 @@ - (void)applicationDidEnterBackground:(UIApplication *)application {

- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
[self checkConsentStates];
}


@@ -70,6 +70,13 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cRK-SZ-J3U">
<rect key="frame" x="16" y="265.5" width="140" height="30"/>
<state key="normal" title="Show app settings..."/>
<connections>
<action selector="showAppSettingsAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ovm-jD-3Vs"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
@@ -81,6 +88,7 @@
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="hLJ-Vj-b24" secondAttribute="trailing" constant="16" id="BAr-bw-bdK"/>
<constraint firstItem="nrb-0G-edZ" firstAttribute="leading" secondItem="rUk-1Y-qgO" secondAttribute="leading" id="BaH-gn-ewk"/>
<constraint firstItem="rUk-1Y-qgO" firstAttribute="leading" secondItem="hLJ-Vj-b24" secondAttribute="leading" id="C2f-ah-Koy"/>
<constraint firstItem="cRK-SZ-J3U" firstAttribute="top" secondItem="4EG-ux-VLA" secondAttribute="bottom" constant="16" id="Cd4-tS-hEV"/>
<constraint firstItem="4EG-ux-VLA" firstAttribute="top" secondItem="jy8-Hk-hC8" secondAttribute="bottom" constant="32" id="Ge3-sX-2x5"/>
<constraint firstItem="rUk-1Y-qgO" firstAttribute="height" secondItem="mXu-XI-mUt" secondAttribute="height" id="H2C-dP-KzZ"/>
<constraint firstItem="jy8-Hk-hC8" firstAttribute="top" secondItem="mXu-XI-mUt" secondAttribute="bottom" constant="8" id="J9i-Fg-3vQ"/>
@@ -94,6 +102,7 @@
<constraint firstItem="hLJ-Vj-b24" firstAttribute="centerY" secondItem="TxH-0L-2UB" secondAttribute="centerY" id="Rvd-OI-OXn"/>
<constraint firstItem="hLJ-Vj-b24" firstAttribute="width" secondItem="hLJ-Vj-b24" secondAttribute="height" multiplier="1:1" id="SIw-LN-BH3"/>
<constraint firstItem="nrb-0G-edZ" firstAttribute="width" secondItem="nrb-0G-edZ" secondAttribute="height" multiplier="1:1" id="Wd8-EQ-ILT"/>
<constraint firstItem="cRK-SZ-J3U" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="16" id="Y1i-wm-kqK"/>
<constraint firstItem="hLJ-Vj-b24" firstAttribute="leading" secondItem="TxH-0L-2UB" secondAttribute="trailing" priority="750" constant="12" id="bWa-RP-QOD"/>
<constraint firstItem="gjC-OR-EYS" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="16" id="eVs-3Y-p8s"/>
<constraint firstItem="4EG-ux-VLA" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="16" id="env-Ub-O0P"/>
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Group</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>privacy-consent</string>
<key>Key</key>
<string>smartlook-consent-sdk-privacy-consent</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>analytics-consent</string>
<key>Key</key>
<string>smartlook-consent-sdk-analytics-consent</string>
<key>DefaultValue</key>
<true/>
</dict>
</array>
</dict>
</plist>
@@ -22,25 +22,21 @@ @implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];

[super viewDidLoad];

//privacyConsentIndicator.layer.cornerRadius = 3
//analyticsConsentIndicator.layer.cornerRadius = 3

[self updateConsentIndicators];

NSMutableArray *consentsSettingsDefaults = [NSMutableArray new];
[consentsSettingsDefaults addObjectsFromArray:@[SLCConsentPrivacy, @(SLCConsentStateProvided)]];
[consentsSettingsDefaults addObjectsFromArray:@[SLCConsentAnalytics, @(SLCConsentStateNotProvided)]];

[SmartlookConsentSDK checkWith:consentsSettingsDefaults callback:^{
// this is not necessary if all the logic is handled in the `SmartlookConsentSDK.check` or `SmartlookConsentSDK.show` callbacks
// may be usefull eg., if some UI depends on the consents state like here
[[NSNotificationCenter defaultCenter] addObserverForName:SLCConsentsTouchedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self updateConsentIndicators];
if ([SmartlookConsentSDK consentStateFor:SLCConsentAnalytics] == SLCConsentStateProvided) {
// start analytics tools
};
}];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self updateConsentIndicators];
}

- (UIColor *)colourForState:(SLCConsentState)state {
switch (state) {
case SLCConsentStateUnknown:
@@ -71,4 +67,13 @@ - (IBAction)buttonAction:(id)sender {
}];
}

- (IBAction)showAppSettingsAction:(id)sender {
NSURL *settingsUrl = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:settingsUrl]) {
[[UIApplication sharedApplication] openURL:settingsUrl options:@{} completionHandler:nil];
}

}


@end
@@ -13,6 +13,7 @@
338579D7221AD647006861C1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 338579D6221AD647006861C1 /* Assets.xcassets */; };
338579DA221AD647006861C1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 338579D8221AD647006861C1 /* LaunchScreen.storyboard */; };
338579EB221AE6F4006861C1 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 338579E9221AE6F4006861C1 /* Localizable.strings */; };
33891F2822201EDD007BECD6 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 33891F2722201EDD007BECD6 /* Settings.bundle */; };
33C27E5D221C08320026F090 /* SmartlookConsentSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33C27E5C221C08320026F090 /* SmartlookConsentSDK.framework */; };
33C27E5E221C08320026F090 /* SmartlookConsentSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 33C27E5C221C08320026F090 /* SmartlookConsentSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
@@ -40,8 +41,8 @@
338579D9221AD647006861C1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
338579DB221AD647006861C1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
338579EA221AE6F4006861C1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
33891F2722201EDD007BECD6 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Settings.bundle; path = ConsentsDemo/Settings.bundle; sourceTree = "<group>"; };
33C27E5C221C08320026F090 /* SmartlookConsentSDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SmartlookConsentSDK.framework; sourceTree = BUILT_PRODUCTS_DIR; };
33EC5379221C0F5E00DE242E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = "/Users/jezovec/Work/Smartlook/ios-consent-sdk/Consents Demo/README.md"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
@@ -59,7 +60,7 @@
338579C3221AD646006861C1 = {
isa = PBXGroup;
children = (
33EC5379221C0F5E00DE242E /* README.md */,
33891F2722201EDD007BECD6 /* Settings.bundle */,
33C27E5C221C08320026F090 /* SmartlookConsentSDK.framework */,
338579CE221AD646006861C1 /* ConsentsDemo */,
338579CD221AD646006861C1 /* Products */,
@@ -149,6 +150,7 @@
files = (
338579DA221AD647006861C1 /* LaunchScreen.storyboard in Resources */,
338579EB221AE6F4006861C1 /* Localizable.strings in Resources */,
33891F2822201EDD007BECD6 /* Settings.bundle in Resources */,
338579D7221AD647006861C1 /* Assets.xcassets in Resources */,
338579D5221AD646006861C1 /* Main.storyboard in Resources */,
);
@@ -7,15 +7,35 @@
//
import UIKit
import SmartlookConsentSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

/** This method is to be invoked any time the app starts to check if the consets are provided
namely in:
- `application:didFinishWithLaunchingOptions` for the fresh start
- `application:WillEnterForeground` for app woken up from background (where possibly the consent setting could be changed in system sessings)
*/
func checkConsentStates() {
var consentsSettingsDefaults = SmartlookConsentSDK.ConsentsSettings()
consentsSettingsDefaults.append((.privacy, .provided))
consentsSettingsDefaults.append((.analytics, .notProvided))
//consentsSettingsDefaults.append(("gdpr", .notProvided)) // adding a custom consent
SmartlookConsentSDK.check(with: consentsSettingsDefaults) {
if SmartlookConsentSDK.consentState(for: .analytics) == .provided {
// start analytics tools
// Smartlook.start(withKey: "1a2b3c4e5f60")
}
}
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
checkConsentStates()
return true
}

@@ -31,10 +51,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
checkConsentStates()
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
@@ -70,6 +70,13 @@
<action selector="reviewConsents:" destination="mXd-qs-Tuh" eventType="touchUpInside" id="D95-ly-sdM"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N5C-JV-HoQ">
<rect key="frame" x="16" y="256" width="140" height="30"/>
<state key="normal" title="Show app settings..."/>
<connections>
<action selector="showAppSettingsAction:" destination="mXd-qs-Tuh" eventType="touchUpInside" id="aFj-yf-QbM"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@@ -92,12 +99,14 @@
<constraint firstItem="7f3-wJ-wxY" firstAttribute="leading" secondItem="lAI-jv-3h8" secondAttribute="leading" constant="16" id="b28-1f-v9X"/>
<constraint firstItem="b7n-LX-fLk" firstAttribute="top" secondItem="7f3-wJ-wxY" secondAttribute="bottom" constant="32" id="b3n-6J-0Zx"/>
<constraint firstItem="dag-Y1-SgF" firstAttribute="height" secondItem="7f3-wJ-wxY" secondAttribute="height" id="bn3-F0-DdW"/>
<constraint firstItem="N5C-JV-HoQ" firstAttribute="top" secondItem="b7n-LX-fLk" secondAttribute="bottom" constant="16" id="c6w-wq-EE8"/>
<constraint firstItem="dag-Y1-SgF" firstAttribute="leading" secondItem="8fo-g4-Czz" secondAttribute="leading" id="cIF-5R-I8g"/>
<constraint firstItem="8fo-g4-Czz" firstAttribute="leading" secondItem="eMH-Ld-eYV" secondAttribute="trailing" priority="750" constant="12" id="cck-we-TX4"/>
<constraint firstItem="7f3-wJ-wxY" firstAttribute="top" secondItem="eMH-Ld-eYV" secondAttribute="bottom" constant="8" id="eCZ-RG-VOO"/>
<constraint firstItem="9XM-0E-dit" firstAttribute="width" secondItem="9XM-0E-dit" secondAttribute="height" multiplier="1:1" id="fjA-r8-MRY"/>
<constraint firstItem="eMH-Ld-eYV" firstAttribute="top" secondItem="niN-6t-20E" secondAttribute="bottom" constant="8" id="h72-Lw-1w1"/>
<constraint firstItem="dag-Y1-SgF" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="7f3-wJ-wxY" secondAttribute="trailing" constant="12" id="jOc-fv-cjd"/>
<constraint firstItem="N5C-JV-HoQ" firstAttribute="leading" secondItem="lAI-jv-3h8" secondAttribute="leading" constant="16" id="jn3-eG-Ram"/>
<constraint firstItem="dag-Y1-SgF" firstAttribute="leading" secondItem="7f3-wJ-wxY" secondAttribute="trailing" priority="750" constant="12" id="k6l-nv-BIP"/>
<constraint firstItem="dag-Y1-SgF" firstAttribute="centerY" secondItem="7f3-wJ-wxY" secondAttribute="centerY" id="kDs-ze-Mhb"/>
<constraint firstItem="xgV-tS-thK" firstAttribute="top" secondItem="lAI-jv-3h8" secondAttribute="top" constant="12" id="s8a-6e-ADY"/>
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Group</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>privacy-consent</string>
<key>Key</key>
<string>smartlook-consent-sdk-privacy-consent</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>analytics-consent</string>
<key>Key</key>
<string>smartlook-consent-sdk-analytics-consent</string>
<key>DefaultValue</key>
<true/>
</dict>
</array>
</dict>
</plist>
Binary file not shown.
Oops, something went wrong.

0 comments on commit 5764203

Please sign in to comment.
You can’t perform that action at this time.