ApesterKit 提供了一个轻量级框架,用于在 webView 中加载 Apester 单元
更新您应用程序的 Info.plist 文件,添加 Apester AdMob 应用 ID。(联系 Apester 获取此 ID)。
For testing please use this key:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
一个用于频道的轮播组件,其中包含媒体发布者的 Apester 单元。 这些单元使用 Apester 平台构建。轮播组件的设计可以配置并显示在任何位置。 请按照我们的分步指南进行设置。
## Swift
private var stripView: APEStripView!
## Objective C
@property (nonatomic, strong) APEStripView *stripView;
## Swift
let header = APEStripHeader(text: "Title", size: 25.0, family: nil, weight: 400, color: .darkText)
let style = APEStripStyle(shape: .roundSquare, size: .medium,
padding: UIEdgeInsets(top: 5.0, left: 0, bottom: 0, right: 0),
shadow: false, textColor: nil, background: nil, header: header)
## Objective C
APEStripHeader *header = [[APEStripHeader alloc] initWithText:@"Title" size:25.0 family:nil weight:400 color:[UIColor purpleColor]];
APEStripStyle *style = [[APEStripStyle alloc] initWithShape:APEStripShapeRoundSquare
size:APEStripSizeMedium
padding:UIEdgeInsetsMake(10.0, 0, 0, 0)
shadow:NO
textColor:nil
background:[UIColor whiteColor]
header:header];
## Swift
let configuration = try? APEStripConfiguration(channelToken: channelToken,
style: style,
bundle: Bundle.main)
## Objective C
NSError *error = nil;
APEStripConfiguration *config = [[APEStripConfiguration alloc] initWithChannelToken:channelToken
style:style
bundle:[NSBundle mainBundle]
error:&error];
## Swift
self.stripView = APEStripView(configuration: config)
## Objective C
self.stripView = [[APEStripView alloc] initWithConfiguration:config];
## Swift
stripView?.display(in: self.containerView, containerViewController: self)
## Objective C
[self.stripView displayIn:self.containerView containerViewController:self];
## Swift
self.stripView.hide()
## Objective C
[self.stripView hide];
一个用于发布者 Apester 媒体的单元或播放列表组件。 这些单元使用 Apester 平台构建。
## Swift
private var unitView: APEUnitView!
## Objective C
@property (nonatomic, strong) APEUnitView *unitView;
## Swift
let unitParams = .unit(mediaId: mediaId)
// OR
let playlistParams = .playlist(tags: tags,
channelToken: channelToken,
context: isContext,
fallback: isFallback)
## Swift
let unitConfig = APEUnitConfiguration(unitParams: unitParams, bundle: Bundle.main)
// OR
let playlistConfig = APEUnitConfiguration(unitParams: playlistParams, bundle: Bundle.main)
## Objective C
APEUnitConfiguration *unitConfig = [[APEUnitConfiguration alloc] initWithMediaId:meidaId bundle: NSBundle.mainBundle];
// OR
APEUnitConfiguration *playlistConfig = [[APEUnitConfiguration alloc] initWithTags: mediaIds
channelToken: channelToken
context: isContext
fallback: isFallback
bundle: NSBundle.mainBundle
gdprString: gdprString
baseUrl: baseUrl];
## Swift
configuration.setFullscreen(true)
## Objective C
[ configuration setFullscreen: true ];
## Swift
self.unitView = APEUnitView(configuration: configuration)
## Objective C
self.unitView = [[APEUnitView alloc] initWithConfiguration:unitConfig];
// OR
self.unitView = [[APEUnitView alloc] initWithConfiguration:playlistConfig];
## Swift
unitView?.display(in: self.containerView, containerViewController: self)
## Objective C
[self.unitView displayIn:self.containerView containerViewController:self];
## Swift
self.unitView.hide()
## Objective C
[self.unitView hide];
## Swift
self.unitView.reload()
## Objective C
[self.unitView reload];
一项服务,用于预缓存 Apester 单元,可以是 APEStripView
或 APEUnitView
。
## Swift
APEViewService.shared.preloadStripViews(with: configurations)
## Objective C
[APEViewService.shared preloadStripViewsWith: configurations];
## Swift
APEViewService.shared.unloadStripViews(with: channelTokens)
## Objective C
[APEViewService.shared unloadStripViewsWith: channelTokens];
## Swift
APEViewService.shared.stripView(for: channelToken)
## Objective C
[APEViewService.shared stripViewFor: channelToken];
## Swift
APEViewService.shared.preloadUnitViews(with: configurations)
## Objective C
[APEViewService.shared preloadUnitViewsWith: configurations];
## Swift
APEViewService.shared.unloadUnitViews(with: unitIds)
## Objective C
[APEViewService.shared unloadUnitViewsWith: unitIds];
## Swift
APEViewService.shared.unitView(for: unitId)
## Objective C
[APEViewService.shared unitViewFor: unitId];
## Swift
apesterUnitView.subscribe(events: ["apester_interaction_loaded", "click_next"]) // example events
## Objective C
NSArray *events = @[@"apester_interaction_loaded"];
[_apesterUnitView subscribeWithEvents:(NSArray<NSString *> * _Nonnull)events];
要订阅的示例事件:(要获取更多事件信息,请联系 Apester 团队)
事件名称 | 含义 |
---|---|
click_next | 点击了“下一步” |
picked_answer | 选择了答案 |
unit_started | 首次参与 |
apester_interaction_loaded | 单元已加载 |
fullscreen_off | 单元全屏已关闭 |
## Swift
apesterUnitView.restart()
## Objective C
[_apesterUnitView restart];
## Swift
configuration.setFullscreen(true)
APEViewService.shared.preloadStripViews(with: configurations)
apesterUnitView.subscribe(events: ["fullscreen_off"]) // add more events as needed
apesterUnitView.delegate = self
func unitView(_ unitView: APEUnitView, didReciveEvent name: String, message: String) {
if name == "fullscreen_off" {
finish();
}
}
if #available(iOS 13.0, *) {
NotificationCenter.default.addObserver(self, selector: #selector(willResignActive), name: UIScene.willDeactivateNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willBackActive), name: UIScene.willEnterForegroundNotification, object: nil)
} else {
NotificationCenter.default.addObserver(self, selector: #selector(willResignActive), name: UIApplication.willResignActiveNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willBackActive), name: UIApplication.willEnterForegroundNotification, object: nil)
}
@objc func willResignActive(_ notification: Notification) {
apesterUnitView.stop()
}
@objc func willBackActive(_ notification: Notification) {
apesterUnitView.resume()
}
override func viewDidDisappear(_ animated: Bool) {
apesterUnitView.stop()
}
override func viewDidAppear(_ animated: Bool) {
apesterUnitView.resume()
}
Swift 包管理器 自动化了 Swift 代码的分发。 要将 ApesterKit 与 SPM 一起使用,请将依赖项添加到您的 Package.swift
文件中
let package = Package(
dependencies: [
.package(url: "https://github.com/Qmerce/ios-sdk.git", from: "2.0.0")
]
)
CocoaPods 是 Cocoa 项目的依赖管理器。 您可以使用以下命令安装它
$ gem install cocoapods
需要 CocoaPods 1.1.0+ 才能构建 ApesterKit。
要使用 CocoaPods 将 ApesterKit 集成到您的 Xcode 项目中,请在您的 Podfile
中指定它
platform :ios, '11.0'
use_frameworks!
pod 'ApesterKit'
然后,运行以下命令
$ pod install
Carthage 是一个去中心化的依赖管理器,它可以自动将框架添加到您的 Cocoa 应用程序中。
您可以使用 Homebrew 安装 Carthage,方法是使用以下命令
$ brew update
$ brew install carthage
要使用 Carthage 将 ApesterKit 集成到您的 Xcode 项目中,请在您的 Cartfile
中指定它
github 'Qmerce/ios-sdk'
然后,运行以下命令
$ carthage update --platform iOS --use-submodules
如果您不想使用上述任何依赖管理器,您可以手动将 ApesterKit 集成到您的项目中。
cd
进入您的顶级项目目录,并运行以下命令“如果”您的项目未初始化为 git 仓库$ git init
$ git submodule add https://github.com/Qmerce/ios-sdk.git
$ git submodule update --init --recursive
ApesterKit
文件夹,并将 ApesterKit.xcodeproj
拖到您的应用程序 Xcode 项目的项目导航器中。它应该嵌套在您的应用程序的蓝色项目图标下。 它是在所有其他 Xcode 组之上还是之下无关紧要。
ApesterKit.xcodeproj
,并验证部署目标与您的应用程序目标相匹配。+
按钮。ApesterKit.xcodeproj
文件夹,每个文件夹都有两个不同版本的 ApesterKit.framework
嵌套在一个 Products
文件夹中。您选择哪个
Products
文件夹并不重要。
选择 ApesterKit.framework
。
就这样!
ApesterKit.framework
会自动添加为目标依赖项、链接框架和嵌入式框架,在复制文件构建阶段中,这是在模拟器和设备上构建所需的一切。
克隆项目并运行 ApesterKitDemo App
1 - clone it `git clone git@github.com:Qmerce/ios-sdk.git`.
2 - run `carthage update`.
3 - select ApesterKitDemo Target.
4 - run the App and enjoy.
ApesterKit 在 MIT 许可下发布。 有关详细信息,请参见 LICENSE。