Skip to content

Commit

Permalink
Merge pull request #3 from chenr2/master
Browse files Browse the repository at this point in the history
Swift 3 review
  • Loading branch information
dandalf authored Apr 27, 2017
2 parents e06cc97 + a7b04ad commit 0bd9ec2
Show file tree
Hide file tree
Showing 95 changed files with 10,068 additions and 5,772 deletions.
117 changes: 65 additions & 52 deletions Example/LotameDMP.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
12 changes: 6 additions & 6 deletions Example/LotameDMP/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

//Set Lotame DMP client id here
DMP.initialize("25")
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

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

func applicationDidBecomeActive(application: UIApplication) {
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) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
32 changes: 18 additions & 14 deletions Example/LotameDMP/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -15,51 +19,51 @@
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EQz-Ke-Fuk">
<rect key="frame" x="204" y="168" width="30" height="30"/>
<rect key="frame" x="91.5" y="168" width="30" height="30"/>
<state key="normal" title="Add"/>
<connections>
<action selector="addBehavior:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Cmu-AJ-hRN"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TQM-dt-5Na">
<rect key="frame" x="282" y="168" width="36" height="30"/>
<rect key="frame" x="169.5" y="168" width="36" height="30"/>
<state key="normal" title="Send"/>
<connections>
<action selector="sendBehaviors:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="gPH-NF-yE1"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2Jr-1L-Cgp">
<rect key="frame" x="368" y="168" width="49" height="30"/>
<rect key="frame" x="255.5" y="168" width="49" height="30"/>
<state key="normal" title="Extract"/>
<connections>
<action selector="getAudience:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="dki-MG-zul"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="D7V-cI-pnN">
<rect key="frame" x="237" y="218" width="126" height="30"/>
<rect key="frame" x="124.5" y="218" width="126" height="30"/>
<state key="normal" title="Start New Session"/>
<connections>
<action selector="startNewSession:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="UZ8-HY-u3q"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="UUID" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NOw-p0-deD">
<rect key="frame" x="20" y="69" width="560" height="21"/>
<rect key="frame" x="16" y="69" width="343" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yyz-Rq-xMN">
<rect key="frame" x="20" y="288" width="560" height="0.0"/>
<rect key="frame" x="16" y="288" width="343" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Lotame DMP Example" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jid-02-hlb">
<rect key="frame" x="183" y="20" width="235" height="29"/>
<rect key="frame" x="70" y="20" width="235" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="235" id="3un-Gz-eta"/>
</constraints>
Expand All @@ -73,20 +77,20 @@
</variation>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Type" textAlignment="natural" minimumFontSize="14" translatesAutoresizingMaskIntoConstraints="NO" id="u4E-GN-0LC">
<rect key="frame" x="20" y="118" width="342" height="30"/>
<rect key="frame" x="16" y="118" width="125" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Value" textAlignment="natural" minimumFontSize="14" translatesAutoresizingMaskIntoConstraints="NO" id="iBB-M3-dSW">
<rect key="frame" x="380" y="118" width="200" height="30"/>
<rect key="frame" x="159" y="118" width="200" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="xlb-2Y-X4M"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="NOw-p0-deD" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="0vf-p9-UQg"/>
<constraint firstItem="Yyz-Rq-xMN" firstAttribute="top" secondItem="D7V-cI-pnN" secondAttribute="bottom" constant="40" id="525-GN-uEj"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -35,4 +45,4 @@
"version" : 1,
"author" : "xcode"
}
}
}
16 changes: 8 additions & 8 deletions Example/LotameDMP/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ class ViewController: UIViewController {
@IBOutlet var valueField: UITextField!


private var foregroundNotification: NSObjectProtocol!
fileprivate var foregroundNotification: NSObjectProtocol!
override func viewDidLoad() {
super.viewDidLoad()
foregroundNotification = NSNotificationCenter.defaultCenter().addObserverForName(UIApplicationWillEnterForegroundNotification, object: nil, queue: NSOperationQueue.mainQueue()) {
foregroundNotification = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIApplicationWillEnterForeground, object: nil, queue: OperationQueue.main) {
[unowned self] notification in
self.showUUID()
}
}

override func viewDidAppear(animated: Bool) {
override func viewDidAppear(_ animated: Bool) {
showUUID()
}

deinit {
NSNotificationCenter.defaultCenter().removeObserver(foregroundNotification)
NotificationCenter.default.removeObserver(foregroundNotification)
}

func showUUID(){
Expand All @@ -43,7 +43,7 @@ class ViewController: UIViewController {
}
}

@IBAction func addBehavior(sender: UIButton) {
@IBAction func addBehavior(_ sender: UIButton) {
self.view.endEditing(true)
if let behavior = behaviorField.text{
DMP.addBehaviorData(valueField.text, forType: behavior)
Expand All @@ -57,7 +57,7 @@ class ViewController: UIViewController {
}
}

@IBAction func sendBehaviors(sender: UIButton) {
@IBAction func sendBehaviors(_ sender: UIButton) {
self.view.endEditing(true)
DMP.sendBehaviorData(){
result in
Expand All @@ -69,7 +69,7 @@ class ViewController: UIViewController {
}
}

@IBAction func getAudience(sender: AnyObject) {
@IBAction func getAudience(_ sender: AnyObject) {
self.view.endEditing(true)
DMP.getAudienceData{
result in
Expand Down Expand Up @@ -97,7 +97,7 @@ class ViewController: UIViewController {

}

@IBAction func startNewSession(sender: AnyObject) {
@IBAction func startNewSession(_ sender: AnyObject) {
DMP.startNewSession()
}

Expand Down
16 changes: 14 additions & 2 deletions Example/ObjcExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

#import "ObjcExample.h"

@import LotameDMP;

@implementation ObjcExample

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Call initialize before making any calls.
[DMP initialize:@"25"]
[DMP initialize:@"25"];
return YES;
}

Expand All @@ -28,10 +30,20 @@ - (void) getAudience{
[DMP getAudienceDataWithHandler:^(LotameProfile * _Nullable profile, BOOL success) {
if (success) { //Check for success
for (LotameAudience * audience in profile.audiences) { //Loop through each audience
NSLog(audience.jsonString)
NSLog(@"%@", audience.jsonString);
}
}
}];
}

- (void) sendBehaviorWithHandler{
[DMP sendBehaviorDataWithHandler: ^(NSError * _Nullable error){
if (error != nil){
NSLog(@"error:: %@", error.description);
} else {
NSLog(@"sendBehaviorDataWithHandler success");
}
}];
}

@end
5 changes: 3 additions & 2 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'LotameDMP_Example', :exclusive => true do
target 'LotameDMP_Example' do
pod "LotameDMP", :path => "../"
end

target 'LotameDMP_Tests', :exclusive => true do
target 'LotameDMP_Tests' do
pod "LotameDMP", :path => "../"
pod 'OHHTTPStubs'

Expand Down
30 changes: 16 additions & 14 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
PODS:
- Alamofire (2.0.2)
- LotameDMP (3.0.0):
- Alamofire (~> 2.0)
- OHHTTPStubs (4.3.0):
- OHHTTPStubs/Default (= 4.3.0)
- OHHTTPStubs/Core (4.3.0)
- OHHTTPStubs/Default (4.3.0):
- Alamofire (4.4.0)
- LotameDMP (4.0.0):
- Alamofire (~> 4.4)
- OHHTTPStubs (6.0.0):
- OHHTTPStubs/Default (= 6.0.0)
- OHHTTPStubs/Core (6.0.0)
- OHHTTPStubs/Default (6.0.0):
- OHHTTPStubs/Core
- OHHTTPStubs/JSON
- OHHTTPStubs/NSURLSession
- OHHTTPStubs/OHPathHelpers
- OHHTTPStubs/JSON (4.3.0):
- OHHTTPStubs/JSON (6.0.0):
- OHHTTPStubs/Core
- OHHTTPStubs/NSURLSession (4.3.0):
- OHHTTPStubs/NSURLSession (6.0.0):
- OHHTTPStubs/Core
- OHHTTPStubs/OHPathHelpers (4.3.0)
- OHHTTPStubs/OHPathHelpers (6.0.0)

DEPENDENCIES:
- LotameDMP (from `../`)
Expand All @@ -25,8 +25,10 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
Alamofire: 8edbab00802a752bb5240cc2abe70e7e881488ad
LotameDMP: 58ef9e6bd216a2af13d78c6aebdbb2bb21ffce99
OHHTTPStubs: 0aec5755528693a165bd616cb79f69387de306a8
Alamofire: dc44b1600b800eb63da6a19039a0083d62a6a62d
LotameDMP: 0defabe7a21938ae7e05038e4c9ac4ebf6a58abe
OHHTTPStubs: 752f9b11fd810a15162d50f11c06ff94f8e012eb

COCOAPODS: 0.38.2
PODFILE CHECKSUM: 50039ae88500faea322d8bcc41901e68028c282f

COCOAPODS: 1.2.1
2 changes: 1 addition & 1 deletion Example/Pods/Alamofire/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0bd9ec2

Please sign in to comment.