PMOSurvey
PMOSurvey 是一个用于向用户展示调查视图的库。它使用 Firebase 配置来收集问题和选项。
示例
要运行示例项目,请克隆仓库,并首先从 Example 目录运行 pod install
。
安装
步骤 1: 下载移动 SDK
PMOSurvey 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'PMOSurvey'
步骤 2: 配置 Firebase 配置
在 Firebase 控制台的导航栏中,单击“远程配置”。添加一个参数或选择一个参数进行编辑
要添加参数:单击“添加参数”。要编辑参数:单击您想要更改的参数。
{
"active": true,
"question": "Where are you from?",
"options": [
"Konya",
"Izmir",
"Istanbul",
"Ankara",
"Edirne"
]
}
第3步:将PMOSurvey SDK整合到您的应用中
- 导入SDK
import PMOSurvey
- 使用调查属性初始化SDK
var prop = PMOSurveyProperties()
prop.plist_key = "pmo_survey"
prop.duration = 10
prop.enable_button_color = UIColor.green
prop.disable_button_color = UIColor.red
PMOSurvey.configure(prop)
- 向用户展示调查
PMOSurvey.shared.isActive { [weak self] (active) in
guard let strongSelf = self else { return }
if active{
PMOSurvey.shared.show(strongSelf, delegate: strongSelf)
}
}
- 委派:调查受访者数据以PMORespondent返回。以下是一个示例
extension ViewController:PMOSurveyDelegate{
func respondentDidEndSurvey(_ response: PMORespondent?, error: Error?) {
if let res = response{
print("question: " + res.question)
print("answer: " + res.answer)
}
}
}
作者
许可
PMOSurvey可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。