ApesterKit 提供了一个轻量级框架,该框架在 webView 中加载 Apester Unit
- iOS 11.0+
- Xcode 10.2+
更新您的 app 的 Info.plist 文件以添加 Apester AdMob 应用 ID。.(联系 Apester 以获取)
For testing please use this key:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
一个包含媒体出版商的 Apester Units 的频道的 Carousel 组件。这些组件是使用 Apester 平台 构建的,Carousel 组件的样式可以配置并显示在任何位置。按照我们的指南逐步设置
## 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 媒体的 Unit 或播放列表组件。这些组件是使用 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 Units 的服务,可以是 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
要构建ApesterKit,需要CocoaPods 1.1.0+。
要将ApesterKit集成到您的Xcode项目中使用CocoaPods,请在您的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手动集成到项目中。
- 打开终端,在顶层项目目录中运行以下命令,如果您的项目尚未初始化为git仓库
$ git init
- 通过运行以下命令将ApesterKit添加为git 子模块
$ 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应用程序
1 - clone it `git clone [email protected]:Qmerce/ios-sdk.git`.
2 - run `carthage update`.
3 - select ApesterKitDemo Target.
4 - run the App and enjoy.
ApesterKit使用MIT许可证发布。有关详细信息,请参阅LICENSE。