iOS SDK for RequestSentinel
将 RequestSentinel 添加到您的 iOS 项目的最简单方法是通过 Swift 包管理器。
- 在 Xcode 中,选择 File > Add Packages...
- 输入此存储库的包 URL request-sentinel-swift。
- 如果是您第一次使用 CocoaPods,请使用
gem install cocoapods
安装 CocoaPods。否则,继续到步骤 3。 - 运行
pod setup
以创建本地 CocoaPods 规范镜像。 - 在您的终端中运行
pod init
以在您的 Xcode 项目目录中创建一个 Podfile,编辑生成的 Podfile,并添加以下行:pod 'request-sentinel-swift'
。 - 在您的 Xcode 项目目录中运行
pod install
。CocoaPods 应该下载并安装 RequestSentinel 库,并创建一个新的 Xcode 工作区。在 Xcode 中打开此工作区或在终端中键入open *.xcworkspace
。
import RequestSentinel
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
....
RequestSentinel.shared.initialize(apiKey: "<API_KEY>",
appVersion: "<YOUR_APP_VERSION>",
appEnvironment: "<YOUR_APP_ENVIRONMENT>")
....
}
}