bg-analytics-ios is an iOS client for ByteGain.
BytegainAnalytics is available through CocoaPods
Add the dependence:
pod "BytegainAnalytics", "4.0.2"
to your Podfile
.
The functioning example is in Examples/CocoapodsExample.
Initialization is done in the Examples/CocoapodsExample/CocoapodsExample/AppDelegate.m:
NSString *const BYTEGAIN_API_KEY = @"YOUR API_KEY GOES HERE";
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[ByteGainAnalytics debug:YES];
ByteGainAnalyticsConfiguration *configuration = [ByteGainAnalyticsConfiguration configurationWithWriteKey:BYTEGAIN_API_KEY];
configuration.trackApplicationLifecycleEvents = YES;
configuration.trackAttributionData = YES;
configuration.recordScreenViews = YES;
configuration.flushAt = 10;
[ByteGainAnalytics setupWithConfiguration:configuration];
The above sets up automatic reporting of screen views and application life cycle events to ByteGain servers.
To send additional event data to ByteGain servers, e.g., button clicks, add calls to the track
method:
- (IBAction)fireEvent:(id)sender
{
[[ByteGainAnalytics sharedAnalytics] track:@"Cocoapods Example Button"];
For more examples, see Examples/CocoapodsExample/CocoapodsExample/ViewController.m.
The code has been tested for Objective-C apps using XCode version 10.1.