PIOViewControllerDemo_Primed.m 2.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
//
//  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"
                                  };
    
Bosko Petreski's avatar
Bosko Petreski committed
34 35 36 37 38 39 40 41 42 43
//    [Primed.sharedInstance personalise:@"frontpage.recommendations" limit:3 abvariantLabel:@"A" success:^(NSDictionary<NSString *,id> *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];
//    }];
    
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    [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
Bosko Petreski's avatar
Bosko Petreski committed
72
    [Primed.sharedInstance initWithPublicKey:@"mypubkey" secretKey:@"mysecretkey" connectionString:@"http://url.here"];
73 74 75 76 77 78
}
-(void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end