Basic Gimbal iOS Sample Integration with Flurry
Objective-C Ruby
Latest commit 6bad8c8 Jun 15, 2016 @garydamm garydamm committed on GitHub Update README.md
Permalink
Failed to load latest commit information.
flurry-integration.xcodeproj
flurry-integration
.gitignore
Podfile
README.md

README.md

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