Leanplum SDK integration for the Segment iOS SDK.
To install the Leanplum Segment integration, simply add this line to your CocoaPods Podfile:
pod 'LeanplumSegment', '~> 1.1.3'
That's it! Now you can use the Segment SDK and also the advanced features of the Leanplum SDK.
Import the LeanplumSegment integration:
#import <LeanplumSegment/SEGLeanplumIntegrationFactory.h>
Add the following lines to your AppDelegate:
NSString *const SEGMENT_WRITE_KEY = @" ... ";
SEGAnalyticsConfiguration *config =
[SEGAnalyticsConfiguration configurationWithWriteKey:SEGMENT_WRITE_KEY];
[config use:[SEGLeanplumIntegrationFactory instance]];
[SEGAnalytics setupWithConfiguration:config];
Now you can use Segment as you are used to, e.g.:
[[SEGAnalytics sharedAnalytics] track:@" ... "];
Note: There is no need to explicitly call Leanplum.start, as it is called within the LeanplumIntegration.
In addition to that you can also use the advanced features of Leanplum. Once the Leanplum SDK is successfully registered, Segement posts a NSNotification, hence register to it:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[...]
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(segmentIntegrationDidStart)
name:SEGAnalyticsIntegrationDidStart
object:LPLeanplumSegmentKey];
}
- (void)segmentIntegrationDidStart {
[Leanplum onVariablesChanged:^{
[...]
}];
}
We have included a sample application.
cd Example && pod install
open LeanplumSegment.xcworkspace
LeanplumSegment_Example
We have included unit tests for the integration.
open LeanplumSegment.xcworkspace
LeanplumSegment_Tests
By default this integration pulls in the latest versions of the Leanplum SDK and the Segment SDK. If you rather want to use a specific version, simply specify the required versions in your podfile directly.
pod 'Analytics', '3.0.1'
pod 'Leanplum-iOS-SDK', '1.2.23'
make deploy
. It will update the version in the header files, commit, tag and try to publish to CocoaPods.
Publish to CocoaPods (Caution, once published cannot be undone!)
The publishing is done automatically when make deploy
is run, using pod trunk push LeanplumSegment.podspec --allow-warnings
called in push.sh
.
You need admin trunk session in order to publish. New session is started using $ pod trunk register
.
See LICENSE file.