Skip to content

Commit

Permalink
Merge pull request #7 from mParticle/Kochava
Browse files Browse the repository at this point in the history
Indirect instantiation of Kochava
  • Loading branch information
peterjenkins committed Feb 3, 2016
2 parents debd16a + 95fa43e commit 9f6440b
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# mParticle iOS SDK CHANGELOG

## 5.2.3

* Indirect instantiation of Kochava to allow it to work in the mParticle SDK with dynamically linked frameworks, `use_frameworks!`, bitcode, and static libraries

## 5.2.2

* Updated the podspec and README to allow for the utilization of `use_frameworks!` and the mParticle SDK
Expand Down

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

22 changes: 11 additions & 11 deletions Pod/Classes/Kits/Kochava/MPKitKochava.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#import "MPKitKochava.h"
#import "MPKochavaSpatialCoordinate.h"
#import "MPEnums.h"
#import "TrackAndAd.h"
#import "MPTrackAndAd.h"

NSString *const kvAppId = @"appId";
NSString *const kvCurrency = @"currency";
Expand All @@ -36,7 +36,7 @@
NSString *const MPUserIdentityIdKey = @"i";
NSString *const MPUserIdentityTypeKey = @"n";

static KochavaTracker *kochavaTracker = nil;
static MPKochavaTracker *kochavaTracker = nil;

@interface MPKitKochava() {
BOOL isNewUser;
Expand All @@ -48,7 +48,7 @@ @interface MPKitKochava() {
@implementation MPKitKochava

#pragma mark Accessors and private methods
- (void)kochavaTracker:(void (^)(KochavaTracker *const kochavaTracker))completionHandler {
- (void)kochavaTracker:(void (^)(MPKochavaTracker *const kochavaTracker))completionHandler {
static dispatch_once_t kochavaPredicate;

dispatch_async(dispatch_get_main_queue(), ^{
Expand Down Expand Up @@ -77,8 +77,8 @@ - (void)kochavaTracker:(void (^)(KochavaTracker *const kochavaTracker))completio
kochavaInfo[@"isNewUser"] = isNewUser ? @"1" : @"0";
}

CFTypeRef kochavaTrackRef = CFRetain((__bridge CFTypeRef)[[KochavaTracker alloc] initKochavaWithParams:kochavaInfo]);
kochavaTracker = (__bridge KochavaTracker *)kochavaTrackRef;
CFTypeRef kochavaTrackRef = CFRetain((__bridge CFTypeRef)[[NSClassFromString(@"KochavaTracker") alloc] initKochavaWithParams:kochavaInfo]);
kochavaTracker = (__bridge MPKochavaTracker *)kochavaTrackRef;

dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary *userInfo = @{mParticleKitInstanceKey:@(MPKitInstanceKochava),
Expand Down Expand Up @@ -123,7 +123,7 @@ - (void)identityLinkCustomerId {
}

if (identityInfo.count > 0) {
[self kochavaTracker:^(KochavaTracker *const kochavaTracker) {
[self kochavaTracker:^(MPKochavaTracker *const kochavaTracker) {
[kochavaTracker identityLinkEvent:(NSDictionary *)identityInfo];
}];
}
Expand Down Expand Up @@ -178,14 +178,14 @@ - (void)identityLinkOtherUserIds {
}

if (identityInfo.count > 0) {
[self kochavaTracker:^(KochavaTracker *const kochavaTracker) {
[self kochavaTracker:^(MPKochavaTracker *const kochavaTracker) {
[kochavaTracker identityLinkEvent:(NSDictionary *)identityInfo];
}];
}
}

- (void)retrieveAttributionWithCompletionHandler:(void(^)(NSDictionary *attribution))completionHandler {
[self kochavaTracker:^(KochavaTracker *const kochavaTracker) {
[self kochavaTracker:^(MPKochavaTracker *const kochavaTracker) {
NSDictionary *attribution = [kochavaTracker retrieveAttribution];
completionHandler(attribution);
}];
Expand All @@ -205,7 +205,7 @@ - (instancetype)initWithConfiguration:(NSDictionary *)configuration {
isNewUser = NO;

__weak MPKitKochava *weakSelf = self;
[self kochavaTracker:^(KochavaTracker *const kochavaTracker) {
[self kochavaTracker:^(MPKochavaTracker *const kochavaTracker) {
__strong MPKitKochava *strongSelf = weakSelf;

if (!strongSelf) {
Expand Down Expand Up @@ -237,7 +237,7 @@ - (void)setConfiguration:(NSDictionary *)configuration {

- (MPKitExecStatus *)setDebugMode:(BOOL)debugMode {
kitDebugMode = debugMode;
[self kochavaTracker:^(KochavaTracker *const kochavaTracker) {
[self kochavaTracker:^(MPKochavaTracker *const kochavaTracker) {
[kochavaTracker enableConsoleLogging:debugMode];
}];

Expand All @@ -246,7 +246,7 @@ - (MPKitExecStatus *)setDebugMode:(BOOL)debugMode {
}

- (MPKitExecStatus *)setOptOut:(BOOL)optOut {
[self kochavaTracker:^(KochavaTracker *const kochavaTracker) {
[self kochavaTracker:^(MPKochavaTracker *const kochavaTracker) {
[kochavaTracker setLimitAdTracking:optOut];
}];

Expand Down
66 changes: 66 additions & 0 deletions Pod/Classes/Kits/Kochava/MPTrackAndAd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// MPTrackAndAd.h
//
// Copyright 2016 mParticle, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "TrackAndAd.h"

@interface MPKochavaTracker : NSObject <KochavaNetworkAccessDelegate, KochavaLocationManagerDelegate, KochavaiAdAttributionDelegate>

#pragma mark - Swift Bridge
- (KochavaTracker*) swiftInitKochavaWithParams:(id)initDict;
- (void) swiftEnableConsoleLogging:(bool)enableLogging;
- (void) swiftTrackEvent:(id)eventTitle :(id)eventValue;
- (void) swiftIdentityLinkEvent:(id)identityLinkData;
- (void) swiftSpatialEvent:(id)eventTitle :(float)x :(float)y :(float)z;
- (void) swiftSetLimitAdTracking:(bool)limitAdTracking;
- (NSString*) swiftRetrieveAttribution;
- (void) swiftSendDeepLink:(id)url :(id)sourceApplication;


#pragma mark - ObjC
- (id) initWithKochavaAppId:(NSString*)appId;
- (id) initWithKochavaAppId:(NSString*)appId :(NSString*)currency;
- (id) initWithKochavaAppId:(NSString*)appId :(NSString*)currency :(bool)enableLogging;
- (id) initWithKochavaAppId:(NSString*)appId :(NSString*)currency :(bool)enableLogging :(bool)limitAdTracking;
- (id) initWithKochavaAppId:(NSString*)appId :(NSString*)currency :(bool)enableLogging :(bool)limitAdTracking :(bool)isNewUser;
- (id) initKochavaWithParams:(NSDictionary*)initDict;

- (void) enableConsoleLogging:(bool)enableLogging;

- (void) trackEvent:(NSString*)eventTitle :(NSString*)eventValue;
- (void) identityLinkEvent:(NSDictionary*)identityLinkData;
- (void) spatialEvent:(NSString*)eventTitle :(float)x :(float)y :(float)z;
- (void) setLimitAdTracking:(bool)limitAdTracking;
- (id) retrieveAttribution;
- (void) sendDeepLink:(NSURL*)url :(NSString*)sourceApplication;

- (NSString*) getKochavaDeviceId;

// Apple Watch
- (void) handleWatchEvents;
- (void) handleWatchEvents:(NSString*)watchLink;
- (void) handleWatchEvents:(NSString*)watchLink :(bool)calledByTrackEvent;

- (void) trackWatchEvent:(NSString*)eventTitle :(NSString*)eventValue;


@property (nonatomic, assign) id <KochavaTrackerClientDelegate> trackerDelegate;

@end
2 changes: 1 addition & 1 deletion Pod/Classes/MPIConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
NSUInteger kMPNumberOfMessageTypes = 17;

// mParticle SDK Version
NSString *const kMParticleSDKVersion = @"5.2.2";
NSString *const kMParticleSDKVersion = @"5.2.3";

// Session Upload Settings
NSString *const kMPSessionHistoryValue = @"sh";
Expand Down
4 changes: 1 addition & 3 deletions mParticle-iOS-SDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "mParticle-iOS-SDK"
s.version = "5.2.2"
s.version = "5.2.3"
s.summary = "mParticle iOS SDK."

s.description = <<-DESC
Expand Down Expand Up @@ -98,8 +98,6 @@ Pod::Spec.new do |s|
ss.dependency 'Kochava'
ss.prefix_header_contents = "#define MP_KIT_KOCHAVA 1"
ss.platform = :ios, '7.0'
ss.pod_target_xcconfig = {'FRAMEWORK_SEARCH_PATHS' => '$(inherited) $(PODS_ROOT)/Kochava',
'OTHER_LDFLAGS' => '$(inherited) -undefined dynamic_lookup'}
end

s.subspec 'Localytics' do |ss|
Expand Down

0 comments on commit 9f6440b

Please sign in to comment.