SOP iOS SDK(Beta)
此库允许您将合作伙伴调查集成到您的iOS应用中
要求
- iOS 8.0+
- Swift 5
- 您需要成为合作伙伴调查的合作伙伴。如果您有兴趣,请联系我们。
- 阅读SOP v1.1 文档并集成您的webservice与SOP。
- 在您的webservice上创建一个用于
研究调查投递通知
的端点,并通过您选择的媒体(如推送通知)通知目标成员。创建研究调查投递通知端点是使用SOP iOS SDK所必需的。
入门
CocoaPods
将以下行添加到您的Podfile中
Swift 5
pod 'SurveyonPartners'
Swift 3
pod 'SurveyonPartners', '0.0.10'
运行以下命令
$ pod install
使用方式
配置
SurveyonPartners.setUp(appId: "your-app-id",
appMid: "user-app-mid",
secretKey: "your-secret-key")
显示调查列表页面
如果您想使用预定义的页面来显示调查,请调用 showSurveyList 方法。
SurveyonPartners.showSurveyList(vc: self,
profilingPointRule: MyProfilingRule(),
researchPointRule: MyResearchPointRule())
要调用 showSurveyList 方法,您需要创建一个实现了 ProfilingPointRule 的类,以及一个实现了 ResearchPointRule 和 Parcelable 的类。
class MyProfilingRule: ProfilingPointRule {
func profilingPoint(profiling: Profiling) -> String {
//Please return points of general profile questionnaire.
//Profile questionnaire are successive. It’s good to use word like “each”
return "2 each"
}
func googleAuthProfilingPoint(profiling: Profiling) -> String {
//Please return points of profile questionnaire for registering Google account.
return "5"
}
func facebookAuthProfilingPoint(profiling: Profiling) -> String {
//Please return points of profile questionnaire for registering Facebook account.
return "4"
}
func cookieProfilingPoint(profiling: Profiling) -> String {
//Please return points of profile questionnaire for registering cookie.
return "6"
}
}
class MyResearchPointRule: ResearchPointRule {
func researchPoint(research: Research) -> String {
//Implement your domain logic to decide point for the research survey
let loi: Int = Int(research.loi)!
var point = "0"
if (0 <= loi && loi < 3) {
point = "100";
} else if (loi < 5) {
point = "200";
} else {
point = "300";
}
return point
}
}
自定义用户界面显示调查
如果您想自定义界面来显示调查,请调用 getSurveyList 方法获取调查。同时,此方法会自动在SOP服务器上注册广告ID。
SurveyonPartners.getSurveyList(completion: { (result) -> Void in
switch result {
case .success(let response):
//success
case .failed(let error):
//failed
}
})
直接调用SOP API
您也可以不使用SOP iOS SDK直接请求SOP API。请参阅SOP v1.1 文档。如果您想在移动设备上使用SOP,请确保您需要实现以下功能。
- 带有survey_id q000_cookie的配置问卷应在浏览器应用程序中打开,而不是在您的应用程序的WebView中。因为该调查在浏览器应用程序中收集cookie以交付广告跟踪调查。
- 调用参与者注册API注册广告ID。