实用的工具用于在iOS应用程序开发中实现发送反馈

网友投稿 670 2022-10-30

实用的工具用于在iOS应用程序开发中实现发送反馈

实用的工具用于在iOS应用程序开发中实现发送反馈

FeedbackKit

feedback tool for iOS app

Feature

[x]Send feedback by mail[x]Send feedback by custom action[ ]Mask privacy info before getting screen capture

You can also send feedback to a platform, such as Slack by using custom action.

Requirements

iOS8.0+Xcode 7.3+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build FeedbackKit.

To integrate FeedbackKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'use_frameworks!pod 'FeedbackKit'

Then, run the following command:

$ pod install

Carthage

Coming soon (Welcome Pull Request)

Usage

Show feedback-view for sending feedback to one user by Email

import FeedbackKitlet emailConifg = Feedback.EmailConfig(to: "hoge@hogehogehoge.jp")Feedback.Email(emailConfig: emailConifg).show { print("dismissed")}

Show feedback-view for sending feedback to multiple users by Email, and setting custom mail subject

let emailConfig = Feedback.EmailConfig(toList: ["hoge1@hogehogehoge.jp", "hoge2@hogehogehoge.jp"])emailConfig.ccList = ["hoge3@hogehogehoge.jp", "hoge4@hogehogehoge.jp"]emailConfig.bccList = ["hoge5@hogehogehoge.jp", "hoge6@hogehogehoge.jp"]emailConfig.mailSubject = "custom mail subject"Feedback.Email(emailConfig: emailConfig).show { print("## dismissed")}

Show feedback-view by 2 finger long press

Please use 'addDoubleLongPressGestureRecognizer' method, do not use 'show' method.

let emailConifg = Feedback.EmailConfig(to: "hoge@hogehogehoge.jp")Feedback.Email(emailConfig: emailConifg).addDoubleLongPressGestureRecognizer { print("dismissed")}

Show feedback-view for sending feedback to Slack by using custom action

Please use 'Custom' enum. At first, please let me explain a basic rule of custom action. If you use 'Custom' enum, you must call 'success' method when custom action was finished successfully. If you do not call 'success' method, feedback-view will not be disappeared.

Feedback.Custom { (feedbackViewController, sendInformation, success) in print("custom action") success() // important method}.show { print("dismissed")}

Next, let's implement a logic for sending to Slack. I think that using SlackKit is a shortcut of goal.

If you use cocoapods, please add SlackKit as follows.

pod 'SlackKit'

and you need to get slack's web api token.

useful link for creating slack's web api token as follows. https://api.slack.com/docs/oauth-test-tokens

import SlackKitFeedback.Custom { (feedbackViewController, sendInformation, success) in let token = "please put your slack's web api token" let bot = SlackKit(withAPIToken: token) guard let client: Client = bot.clients[token] else { return } guard let imageData = sendInformation.captureImageData else { return } let selectedTitle = sendInformation.selectedTitle ?? "" let comment = sendInformation.comment ?? "" let reporterName = sendInformation.reporterName ?? "" let className = sendInformation.className ?? "" client.webAPI.uploadFile(imageData, filename: "feedback", channels: ["#image_upload_your_channel"], success: { (file) in guard let imageUrl = file.urlPrivate else { return } let attachment = Attachment(fallback: "You got new feedback", title: selectedTitle, text: "\(className) : \(comment) by \(reporterName)", imageURL: imageUrl) // text and image client.webAPI.sendMessage("#feedback_your_channel", text: "You got new feedback", username: "feedback", attachments: [attachment], success: { (complete:(ts: String?, channel: String?)) in print("## message success ") success() // important method. need to call this method for dismiss feedback view }, failure: { (error) in print("## message fail \(error)") }) }) { (error) in print("## upload failure") }}.show { print("dismissed")}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:【多线程】 锁策略 ( 悲观/乐观锁 、读写/互斥锁 、重量/轻量级锁、挂起等待/自旋锁 、公平/非公平锁 、可重入/不可重入锁)
下一篇:【HJ68】成绩排序(stable_sort)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~