Leanplum Segment iOS 集成
LeanplumSDK 对 Segment iOS SDK 的集成。
安装
要安装 Leanplum Segment 集成,只需将此行添加到您的 CocoaPods Podfile 中
pod 'LeanplumSegment', '~> 1.1.3'
就是这样!现在您可以使用 Segment SDK,同时还可以使用 Leanplum SDK 的 高级功能。
用法
导入 LeanplumSegment 集成
#import <LeanplumSegment/SEGLeanplumIntegrationFactory.h>
将以下行添加到您的 AppDelegate 中
NSString *const SEGMENT_WRITE_KEY = @" ... ";
SEGAnalyticsConfiguration *config =
[SEGAnalyticsConfiguration configurationWithWriteKey:SEGMENT_WRITE_KEY];
[config use:[SEGLeanplumIntegrationFactory instance]];
[SEGAnalytics setupWithConfiguration:config];
现在您可以使用 Segment,就像您过去一样,例如
[[SEGAnalytics sharedAnalytics] track:@" ... "];
注意:不需要显式调用 Leanplum.start,因为 LeanplumIntegration 中已经调用了它。
此外,您还可以使用 Leanplum 的高级功能。一旦 Leanplum SDK 成功注册,Segment 会发布一个 NSNotification,因此请注册它
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[...]
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(segmentIntegrationDidStart)
name:SEGAnalyticsIntegrationDidStart
object:LPLeanplumSegmentKey];
}
- (void)segmentIntegrationDidStart {
[Leanplum onVariablesChanged:^{
[...]
}];
}
示例
我们包含了一个示例应用程序。
- 在示例项目中安装CocoaPods:
cd Example && pod install
- 要运行示例应用程序
open LeanplumSegment.xcworkspace
- 选择并运行目标
LeanplumSegment_Example
测试
我们为集成包含单元测试。
- 要运行单元测试
open LeanplumSegment.xcworkspace
- 选择并测试目标
LeanplumSegment_Tests
安装特定版本的 SDK
默认情况下,此集成会拉取 Leanplum SDK 和 Segment SDK 的最新版本。如果您想使用特定版本,只需直接在 podfile 中指定所需版本即可。
pod 'Analytics', '3.0.1'
pod 'Leanplum-iOS-SDK', '1.2.23'
部署到 CocoaPods
- 从 develop 分支检出新的发布分支
git flow release start "NEW_VERSION"
- 运行版本升级脚本
./bump_version.sh OLD_VERSION NEW_VERSION
- 在 Example 项目中运行单元测试。
- 验证库
pod lib lint --use-libraries --verbose
pod spec lint --use-libraries --verbose
- 完成发布
git flow release finish "NEW_VERSION"
git push
git checkout master
git push
- 发布到 CocoaPods(注意,一旦发布后无法撤销!)
pod trunk push --use-libraries
许可证
查看 LICENSE 文件。