Skip to content

gimbalinc/flurry-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gimbal Flurry Integration

This sample project shows how Gimbal can be integrated with Flurry.

In this integration information regarding Place events are sent to Flurry. You can than use this information from within Flurry's analytic tools.

Setup

Please refer to the hello-gimbal-ios sample application for generic Gimbal setup and dependencies.

You will need to enter your Gimbal API Key and Flurry API Key into the AppDelegate.m file.

GimbalFlurryAdapter

To make integration easier we have created a helper class GimbalFlurryAdapter that exposes a simple method

[GimbalFlurryAdapter sharedInstanceWithGimbalAPIKey:@"GIMBAL_API_KEY_HERE"
                                    andFlurryAPIKey:@"FLURRY_API_KEY_HERE"];

By invoking this method with the appropriate Gimbal and Flurry API keys both frameworks are initialized and place events are monitored and sent to Flurry.

The project is based on hello-gimbal-ios project. With the following changes

The code for GimbalFlurryAdapter shows how Place events are sent to Flurry.

#import "GimbalFlurryAdapter.h"
#import "Flurry.h"
#import <Gimbal/Gimbal.h>

@interface GimbalFlurryAdapter() <GMBLPlaceManagerDelegate>

@property (nonatomic) GMBLPlaceManager *placeManager;

@end

@implementation GimbalFlurryAdapter

+ (instancetype) sharedInstanceWithGimbalAPUKey:(NSString *)gimbalAPIKey withFlurryAPIKey:(NSString *)flurryAPIKey
{
    static dispatch_once_t p = 0;
    __strong static id _sharedObject = nil;
    dispatch_once(&p, ^{
        [Flurry startSession:flurryAPIKey];
        [Gimbal setAPIKey:gimbalAPIKey options:nil];
        _sharedObject = [[self alloc] init];
    });
    return _sharedObject;
}

-(instancetype) init {
    self = [super init];
    if (self) {
        self.placeManager = [GMBLPlaceManager new];
        self.placeManager.delegate = self;
        [GMBLPlaceManager startMonitoring];
        NSLog(@"GIMBAL and FLURRY initialized");
    }
    return self;
}

- (NSDictionary*)buildVisitParameters:(GMBLVisit *)visit
{
    
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{@"visitId" : visit.visitID,
                                                                                      @"placeId" : visit.place.identifier,
                                                                                      @"placeName" : visit.place.name}];
    
    for (NSString* key in [visit.place.attributes allKeys])
    {
        NSString* value = [visit.place.attributes stringForKey:key];
        [parameters setValue:value forKey:key];
    }
    
    return parameters;
}

# pragma mark - Gimbal Place Manager Delegate methods

- (void)placeManager:(GMBLPlaceManager *)manager didBeginVisit:(GMBLVisit *)visit
{
    NSLog(@"Logging didBeginVisit to Flurry for %@", [visit description]);
    [Flurry logEvent:@"didBeginVisit" withParameters:[self buildVisitParameters:visit]];
}

- (void)placeManager:(GMBLPlaceManager *)manager didEndVisit:(GMBLVisit *)visit
{
    NSLog(@"Logging didEndVisit to Flurry for %@", [visit description]);
    [Flurry logEvent:@"didEndVisit" withParameters:[self buildVisitParameters:visit]];
}

@end

About

Basic Gimbal iOS Sample Integration with Flurry

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published