要求
- Cocoapods
- iOS 8.0及以上
安装
CocoaPods
- 将以下行添加到您的Podfile
pod 'OneMarket'
- 运行
pod install
手动
-
将OneMarket.framework拖入您的Xcode项目(目标设置 -> 一般 -> 嵌入的二进制文件)
-
确保在添加文件对话框中选择"需要时复制项目"
设置
在开始之前,请确保遵循以下步骤,以便使您的项目准备就绪
- 如果这些属性不存在,请将以下属性添加到您的Info.plist文件中
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Your location usage description goes here.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Your location usage description goes here.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location usage description goes here.</string>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>
- 不要忘记更新上述描述,以更好地反映您的应用功能。
- 确保目标设置中能力选项卡中的
后台模式
开关是打开的。
使用方法
Swift
- 在您的应用程序代理文件中导入框架
import OneMarket
- 将以下行添加到您的
application(_:didFinishLaunchingWithOptions:)
方法中
OneMarket.start(withAppId: "Your-App-ID", appKey: "Your-App-Key")
- 将
"Your-App-ID"
替换为提供的 AppID。 - 将
"Your-App-Key"
替换为提供的 AppKey。
Objective-C
- 在您的应用程序代理实现文件中导入框架
@import OneMarket;
- 将以下行添加到您的
application:didFinishLaunchingWithOptions:
方法中
[OneMarket startWithAppId:@"Your-App-ID" appKey:@"Your-App-Key"];
- 将
@"Your-App-ID"
替换为提供的 AppID。 - 将
@"Your-App-Key"
替换为提供的 AppKey。