Flyreel SDK
安装
CocoaPods
将 pod Flyreel
添加到您的 Podfile 中
pod Flyreel
Swift 包管理器
- 按照 Apple 的指南 将包依赖项添加到您的应用程序中。
- 搜索
https://github.com/Flyreel/flyreel-sdk-ios
包。
初始化
要使用 Flyreel SDK,您必须提供以下参数的配置
settingsVersion
:您的远程 SDK 设置的标识符。
organizationId
:您的组织标识符。
let configuration = FlyreelConfiguration(
settingsVersion: "1",
organizationId: "7d3899f1421a7650241516475"
)
FlyreelSDK.shared.set(configuration: configuration)
设置配置是强制性的。尝试在没有配置的情况下打开 SDK 流将导致致命错误。
权限
由于 SDK 激活使用了一些 iOS 系统的功能,您需要提供一些权限设置
<key>NSCameraUsageDescription</key>
<string>We need access to the camera.</string>
<key>NSMicrophoneUsageDescription</key>
<string>We need access to the camera.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need access to your location data</string>
如何显示 UI
SwiftUI
对于 SwiftUI,使用我们自定义的类似于常规折叠面板呈现的修饰符
@State private var isFlowPresented = false
var body: some View {
Button("Open Flyreel flow") {
isFlowPresented = true
}
.presentFlyreel(isPresented: $isFlowPresented)
}
UIKIt
对于UIKit,将Flyreel流程呈现到任意UIViewController上
FlyreelSDK.shared.presentFlyreel(on: self)
深链接
如果您从深链接、推送通知或可自动提供用户详情的自定义解决方案中启动Flyreel流程,请使用
SwiftUI
func presentFlyreel(
isPresented: Binding<Bool>,
zipCode: String,
accessCode: String,
shouldSkipLoginPage: Bool = true
)
func presentFlyreel(
isPresented: Binding<Bool>,
deepLinkURL: URL,
shouldSkipLoginPage: Bool = true
)
UIKit
func presentFlyreel(
on rootViewController: UIViewController,
zipCode: String,
accessCode: String,
shouldSkipLoginPage: Bool = true,
animated: Bool = true
)
func presentFlyreel(
on rootViewController: UIViewController,
deepLinkURL: URL,
shouldSkipLoginPage: Bool = true,
animated: Bool = true
)
调试日志
启用调试日志以 Troubleshooting 故障排除
FlyreelSDK.shared.enableLogs()
沙盒
在沙盒模式下验证您的实现。使用配置开关环境
let configuration = FlyreelConfiguration(
settingsVersion: "1",
organizationId: "7d3899f1421a7650241516475",
environment: .sandbox
)
FlyreelSDK.shared.set(configuration: configuration)