KAppStoreFeedback
简单收集用户反馈,如果好评则跳转到 AppStore,如果你评价不好,则跳转到帮助中心/支持邮箱。
演示
功能
- 通过电子邮件发送反馈
- 发送反馈到帮助中心链接
- 发送反馈到 AppStore
- 三种自定义 UI 的反馈模式
要求
- iOS 9.0+
- Xcode 9+
安装
Cocoapods
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它:
$ gem install cocoapods
要使用 CocoaPods 将 FeedbackKit 集成到您的 Xcode 项目中,请在您的 Podfile
中指定它:
platform :ios, '11.0'
use_frameworks!
pod 'KAppStoreFeedback'
然后,运行以下命令:
$ pod install
使用(必须):
在您希望显示弹窗的任何 Viewcontroller 上初始化 KAppStoreFeedback:
复制粘贴以下代码:
import KAppStoreFeedback
override func viewDidLoad() {
super.viewDidLoad()
KAppStoreFeedBackView.shared.initializeKAppStoreFeedBackView(hostingViewController: self, navigationConfig: getKAppStoreFeedbackNavigationConfig(), config: getKAppStoreFeedbackConfig(), configUIElements: nil)
}
func getKAppStoreFeedbackConfig () -> KAppStoreFeedbackConfig {
return KAppStoreFeedbackConfig(kASFFeedbackType: KAppStoreFeedbackType.ratingsView, minimumLoginAttempt: 10)
}
func getKAppStoreFeedbackNavigationConfig () -> KAppStoreFeedbackNavigationConfig {
return KAppStoreFeedbackNavigationConfig(iTunesLink: "my App store link", helpEmail: "help email used if help link not provided ", helpLink: "URL to support page or Ticketing page", callBackdelegate: nil)
}
使用(可选 - 自定义):
要在不同的反馈弹窗类型之间进行切换 -
替换所需的弹窗类型的 getKAppStoreFeedbackConfig() 方法。
弹窗评分视图类型 - KAppStoreFeedbackType.ratingsView
func getKAppStoreFeedbackConfig () -> KAppStoreFeedbackConfig {
return KAppStoreFeedbackConfig(kASFFeedbackType: KAppStoreFeedbackType.ratingsView, minimumLoginAttempt: 10)
}
警报表情视图类型 - KAppStoreFeedbackType.emoticonsView
func getKAppStoreFeedbackConfig () -> KAppStoreFeedbackConfig {
return KAppStoreFeedbackConfig(kASFFeedbackType: KAppStoreFeedbackType.emoticonsView, minimumLoginAttempt: 10)
}
警报点赞视图类型 - KAppStoreFeedbackType.thumbsView
func getKAppStoreFeedbackConfig () -> KAppStoreFeedbackConfig {
return KAppStoreFeedbackConfig(kASFFeedbackType: KAppStoreFeedbackType.thumbsView, minimumLoginAttempt: 10)
}
自定义UI外观和感觉
请创建一个KAppStoreFeedbackUIElementsConfig对象并在初始化时传入
func getKAppStoreFeedbackUIElementsConfig () -> KAppStoreFeedbackUIElementsConfig {
let myColor = UIColor.gray
let myFont = UIFont.systemFont(ofSize: 20.0)
return KAppStoreFeedbackUIElementsConfig(alertBackgroundColor: myColor,
alertBorderColor: myColor,
alertTitleBackgroundColor: myColor,
alertTitleFontColor: myColor,
alertMessageFontColor: myColor,
alertNotNowButtonFontColor: myColor,
alertRateButtonFontColor: myColor,
alertHelpButtonFontColor: myColor,
alertCornerRadius: 10 ,
alertTitleFont: myFont,
alertMessageFont: myFont,
alertSecondryButtonFont: myFont,
alertPrimaryButtonFont: myFont)
}
自定义反馈交互的导航
请创建一个KAppStoreFeedbackNavigationConfig对象并在初始化时传入
链接方法
func getKAppStoreFeedbackNavigationConfig () -> KAppStoreFeedbackNavigationConfig {
return KAppStoreFeedbackNavigationConfig(iTunesLink: "my App store link",
helpEmail: "help email used if help link not provided ",
helpLink: "URL to support page or Ticketing page",
callBackdelegate: nil)
}
委托/回调方法
func getKAppStoreFeedbackNavigationConfig () -> KAppStoreFeedbackNavigationConfig {
return KAppStoreFeedbackNavigationConfig(iTunesLink: nil, helpEmail: nil, helpLink: nil, callBackdelegate: self)
}
//MARK:- KAppStoreFeedbackProtocol
func navigateToPossitiveFeedBackHandler() {
TODO: handle possitive interaction
}
func navigateToNegativeFeedBackHandler() {
TODO: Handle negetive interaction
}
自定义反馈提醒中的文本
请创建一个 KAppStoreFeedbackConfig 对象并在初始化时传递。
func getKAppStoreFeedbackConfig () -> KAppStoreFeedbackConfig {
return KAppStoreFeedbackConfig(kASFFeedbackType: KAppStoreFeedbackType.emoticonsView ,
title: "Custom Title",
message: "Custom Message",
notNowButtonTitle: "Not now text",
rateButtonTitle: "Rate button text",
helpButtonTitle: "help button text",
minimumLoginAttempt: 10)
}