The Keen IO iOS client is designed to be simple to develop with, yet incredibly flexible. Our goal is to let you decide what events are important to you, use your own vocabulary to describe them, and decide when you want to send them to Keen IO.
Use cocoapods to install! Just add a line to your Podfile like so:
pod 'KeenClient'
Then run
pod install
Make sure to add CoreLocation.framework to the "Link Binary with Libraries" section.
Also enable the "-ObjC" linker flag under "Other Linker Flags".
Voila!
For other methods, see our detailed documentation here.
To use this client with the Keen IO API, you have to configure your Keen IO Project ID and its access keys (if you need an account, # here - it's free).
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[KeenClient sharedClientWithProjectId:@"your_project_id" andWriteKey:@"your_write_key" andReadKey:@"your_read_key"];
}
The write key is required to send events to Keen IO - the read key is required to do analysis on Keen IO.
Use the client like so:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:@"first view", @"view_name",
@"going to", @"action", nil];
[[KeenClient sharedClient] addEvent:event toEventCollection:@"tab_views" error:nil];
}
Adding events just stores the events locally on the device. You must explicitly upload them to Keen IO. Here's an example:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIBackgroundTaskIdentifier taskId = [application beginBackgroundTaskWithExpirationHandler:^(void) {
NSLog(@"Background task is being expired.");
}];
[[KeenClient sharedClient] uploadWithFinishedBlock:^(void) {
[application endBackgroundTask:taskId];
}];
}
TODO
That's it! After running your code, check your Keen IO Project to see the event has been added.
- Changed project token -> project ID.
- Added support for read and write scoped keys.
- Added support for travis.
- Support analysis APIs.
- Native iOS visualizations.
If you have any questions, bugs, or suggestions, please report them via Github Issues. Or, come chat with us anytime at users.keen.io. We'd love to hear your feedback and ideas!
This is an open source project and we love involvement from the community! Hit us up with pull requests and issues.