Commit 4d918780 authored by Bosko Petreski's avatar Bosko Petreski Committed by Bosko Petreski

added demo application for primed and primed tracker

parent 7da66330
......@@ -21,6 +21,8 @@
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
6D27F3B5214A472200D0702D /* PIOViewControllerDemo_Primed.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D27F3B4214A472200D0702D /* PIOViewControllerDemo_Primed.m */; };
6D27F3B8214A473600D0702D /* PIOViewControllerDemo_PrimedTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D27F3B7214A473600D0702D /* PIOViewControllerDemo_PrimedTracker.m */; };
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; };
854517A5ADD6BD96F0832147 /* Pods_PrimedIO_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F95429C3B970A1F990BB57B9 /* Pods_PrimedIO_Example.framework */; };
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
......@@ -59,6 +61,10 @@
6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
6D27F3B3214A472200D0702D /* PIOViewControllerDemo_Primed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIOViewControllerDemo_Primed.h; sourceTree = "<group>"; };
6D27F3B4214A472200D0702D /* PIOViewControllerDemo_Primed.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIOViewControllerDemo_Primed.m; sourceTree = "<group>"; };
6D27F3B6214A473600D0702D /* PIOViewControllerDemo_PrimedTracker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIOViewControllerDemo_PrimedTracker.h; sourceTree = "<group>"; };
6D27F3B7214A473600D0702D /* PIOViewControllerDemo_PrimedTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIOViewControllerDemo_PrimedTracker.m; sourceTree = "<group>"; };
71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
8ADCB24F272B88B1BCD1CB3E /* Pods-PrimedIO_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PrimedIO_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-PrimedIO_Example/Pods-PrimedIO_Example.release.xcconfig"; sourceTree = "<group>"; };
......@@ -137,6 +143,10 @@
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */,
6003F5A5195388D20070C39A /* PIOViewController.h */,
6003F5A6195388D20070C39A /* PIOViewController.m */,
6D27F3B3214A472200D0702D /* PIOViewControllerDemo_Primed.h */,
6D27F3B4214A472200D0702D /* PIOViewControllerDemo_Primed.m */,
6D27F3B6214A473600D0702D /* PIOViewControllerDemo_PrimedTracker.h */,
6D27F3B7214A473600D0702D /* PIOViewControllerDemo_PrimedTracker.m */,
71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */,
6003F5A8195388D20070C39A /* Images.xcassets */,
6003F594195388D20070C39A /* Supporting Files */,
......@@ -360,6 +370,8 @@
buildActionMask = 2147483647;
files = (
6003F59E195388D20070C39A /* PIOAppDelegate.m in Sources */,
6D27F3B8214A473600D0702D /* PIOViewControllerDemo_PrimedTracker.m in Sources */,
6D27F3B5214A472200D0702D /* PIOViewControllerDemo_Primed.m in Sources */,
6003F5A7195388D20070C39A /* PIOViewController.m in Sources */,
6003F59A195388D20070C39A /* main.m in Sources */,
);
......
This diff is collapsed.
......@@ -7,9 +7,10 @@
//
@import UIKit;
@import CoreLocation;
@interface PIOAppDelegate : UIResponder <UIApplicationDelegate>
@interface PIOAppDelegate : UIResponder <UIApplicationDelegate,CLLocationManagerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) CLLocationManager *locationManager;
@end
......@@ -11,7 +11,23 @@
@implementation PIOAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
self.locationManager = [CLLocationManager new];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
return YES;
}
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
NSLog(@"didFailWithError: %@", error);
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
}
@end
......@@ -7,8 +7,8 @@
//
#import "PIOViewController.h"
#import <PrimedIO/Primed.h>
#import <PrimedIO/PrimedTracker.h>
#import "PIOViewControllerDemo_Primed.h"
#import "PIOViewControllerDemo_PrimedTracker.h"
@interface PIOViewController ()
......@@ -17,49 +17,18 @@
@implementation PIOViewController
#pragma mark - IBActions
-(IBAction)onBtnMakeConvert:(UIButton *)sender{
// Make conversion
// [Primed.sharedInstance convert:@"43b88f01-e3e7-4f8d-a0d2-bcc1f836650a"];
// Make conversion with data
NSDictionary *dictData = @{@"device": @"iphone",
@"userid": @"someuserid"
};
[Primed.sharedInstance convert:@"43b88f01-e3e7-4f8d-a0d2-bcc1f836650a" data:dictData];
-(IBAction)onBtnOpenPrimed:(UIButton *)sender{
PIOViewControllerDemo_Primed *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"Primed"];
[self presentViewController:controller animated:YES completion:nil];
}
-(IBAction)onBtnPersonalise:(UIButton *)sender{
NSDictionary *dictSignals = @{@"device": @"iphone",
@"userid": @"someuserid"
};
[Primed.sharedInstance personalise:@"frontpage.recommendations" signals:dictSignals limit:3 abvariantLabel:@"A" success:^(NSDictionary *response) {
//Handle response
NSLog(@"personalise: %@",response);
} failed:^(NSString *message) {
//Handle message
NSLog(@"personalise error: %@",message);
}];
}
-(IBAction)onBtnCheckHealth:(UIButton *)sender{
[Primed.sharedInstance health:^(NSDictionary *response) {
NSLog(@"health: %@",response);
} failed:^(NSString *message) {
NSLog(@"health error: %@",message);
}];
}
-(IBAction)onBtnTrackView:(UIButton *)sender{
[PrimedTracker.sharedInstance trackView:@"Test View Example"];
-(IBAction)onBtnOpenPrimedTracker:(UIButton *)sender{
PIOViewControllerDemo_PrimedTracker *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"PrimedTracker"];
[self presentViewController:controller animated:YES completion:nil];
}
#pragma mark - UIViewDelegates
-(void)viewDidLoad{
[super viewDidLoad];
// Create Primed instance
// [Primed.sharedInstance initWithPublicKey:@"mypubkey" secretKey:@"mysecretkey" connectionString:@"https://gw.staging.primed.io:443"];
// Create PrimedTracker instance
[PrimedTracker.sharedInstance initWithPublicKey:@"mypubkey" secretKey:@"mysecretkey" connectionString:@"https://gw.staging.primed.io:443" trackingConnectionString:@"http://18.191.69.104:5001/v1" heartbeatInterval:10 eventQueueRetryInterval:10];
}
-(void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
......
//
// PIOViewControllerDemo_Primed.h
// PrimedIO
//
// Created by PrimedIO on 07/10/2018.
// Copyright (c) 2018 PrimedIO. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface PIOViewControllerDemo_Primed : UIViewController{
IBOutlet UITextView *txtConsole;
}
@end
//
// PIOViewControllerDemo_Primed.m
// PrimedIO
//
// Created by PrimedIO on 07/10/2018.
// Copyright (c) 2018 PrimedIO. All rights reserved.
//
#import "PIOViewControllerDemo_Primed.h"
#import <PrimedIO/Primed.h>
@interface PIOViewControllerDemo_Primed ()
@end
@implementation PIOViewControllerDemo_Primed
#pragma mark - IBActions
-(IBAction)onBtnConvert:(UIButton *)sender{
// Make conversion
// [Primed.sharedInstance convert:@"43b88f01-e3e7-4f8d-a0d2-bcc1f836650a"];
// Make conversion with data
NSDictionary *dictData = @{@"device": @"iphone",
@"userid": @"someuserid"
};
[Primed.sharedInstance convert:@"43b88f01-e3e7-4f8d-a0d2-bcc1f836650a" data:dictData];
}
-(IBAction)onBtnPersonalise:(UIButton *)sender{
NSDictionary *dictSignals = @{@"device": @"iphone",
@"userid": @"someuserid"
};
[Primed.sharedInstance personalise:@"frontpage.recommendations" signals:dictSignals limit:3 abvariantLabel:@"A" success:^(NSDictionary *response) {
//Handle response
NSLog(@"personalise: %@",response);
txtConsole.text = [NSString stringWithFormat:@"personalise: %@",response];
} failed:^(NSString *message) {
//Handle message
NSLog(@"personalise error: %@",message);
txtConsole.text = [NSString stringWithFormat:@"personalise error: %@",message];
}];
}
-(IBAction)onBtnCheckHealth:(UIButton *)sender{
[Primed.sharedInstance health:^(NSDictionary *response) {
NSLog(@"health: %@",response);
txtConsole.text = [NSString stringWithFormat:@"health: %@",response];
} failed:^(NSString *message) {
NSLog(@"health error: %@",message);
txtConsole.text = [NSString stringWithFormat:@"health error: %@",message];
}];
}
#pragma mark - UIViewDelegates
-(void)viewDidLoad {
[super viewDidLoad];
// Enable debug
Primed.sharedInstance.debug = YES;
// Create Primed instance
[Primed.sharedInstance initWithPublicKey:@"mypubkey" secretKey:@"mysecretkey" connectionString:@"https://gw.staging.primed.io:443"];
}
-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
//
// PIOViewControllerDemo_PrimedTracker.h
// PrimedIO
//
// Created by PrimedIO on 07/10/2018.
// Copyright (c) 2018 PrimedIO. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface PIOViewControllerDemo_PrimedTracker : UIViewController <UIScrollViewDelegate>{
IBOutlet UITextView *txtConsole;
}
@end
//
// PIOViewControllerDemo_PrimedTracker.m
// PrimedIO
//
// Created by PrimedIO on 07/10/2018.
// Copyright (c) 2018 PrimedIO. All rights reserved.
//
#import "PIOViewControllerDemo_PrimedTracker.h"
#import "PIOAppDelegate.h"
#import <PrimedIO/PrimedTracker.h>
@interface PIOViewControllerDemo_PrimedTracker (){
CGFloat lastContentOffset;
}
@end
@implementation PIOViewControllerDemo_PrimedTracker
#pragma mark - IBActions
-(IBAction)onBtnTrackView:(UIButton *)sender{
// [PrimedTracker.sharedInstance trackView:@"Test View Example"];
[PrimedTracker.sharedInstance trackView:@"Test View Example" customProperties:@{@"id":@"33"}];
}
-(IBAction)onBtnTrackScroll:(UIButton *)sender{
//-(void)trackScroll:(ScrollDirection)scrollDirection distance:(NSInteger)distance;
}
-(IBAction)onBtnTrackEnterViewPort:(UIButton *)sender{
[PrimedTracker.sharedInstance trackEnterViewPort:@{@"name":@"Screen 1"}];
}
-(IBAction)onBtnTrackExitViewPort:(UIButton *)sender{
[PrimedTracker.sharedInstance trackExitViewPort:@{@"name":@"Screen 1"}];
}
-(IBAction)onBtnTrackCustomEvent:(UIButton *)sender{
[PrimedTracker.sharedInstance trackCustomEvent:@"CustomEvenet" customProperties:@{@"id":@"33"}];
}
#pragma mark - UIScroll for TextView
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
lastContentOffset = scrollView.contentOffset.x;
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if (lastContentOffset < scrollView.contentOffset.y) {
double distance = scrollView.contentOffset.y - lastContentOffset;
[PrimedTracker.sharedInstance trackScroll:ScrollDirection_DOWN distance:distance];
}
else {
double distance = lastContentOffset - scrollView.contentOffset.y;
[PrimedTracker.sharedInstance trackScroll:ScrollDirection_UP distance:distance];
}
}
#pragma mark - UIViewDelegates
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
UITouch *aTouch = [touches anyObject];
CGPoint point = [aTouch locationInView:self.view];
//[PrimedTracker.sharedInstance trackClick:point.x y:point.y];
[PrimedTracker.sharedInstance trackClick:point.x y:point.y interactionType:InteractionType_LEFT];
}
-(void)viewDidLoad {
[super viewDidLoad];
// Enable debug
//PrimedTracker.sharedInstance.debug = YES;
// Create PrimedTracker instance
[PrimedTracker.sharedInstance initWithPublicKey:@"mypubkey" secretKey:@"mysecretkey" connectionString:@"https://gw.staging.primed.io:443" trackingConnectionString:@"http://18.191.69.104:5001/v1" heartbeatInterval:10 eventQueueRetryInterval:10];
[NSTimer scheduledTimerWithTimeInterval:10 repeats:YES block:^(NSTimer * _Nonnull timer) {
PIOAppDelegate *appDelegate = (PIOAppDelegate *)[[UIApplication sharedApplication] delegate];
[PrimedTracker.sharedInstance trackPositionChange:appDelegate.locationManager.location];
}];
}
-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
......@@ -60,5 +60,7 @@
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>GPS is used for location changes in Primed Tracker</string>
</dict>
</plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment