TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Apr 2016 |
SPMSupports SPM | ✗ |
Maintained by Wongzigii.
Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event elegantly.
One of the main issues accross the iOS development is the feedback of new features and bug report.
The most common way is to use mailto
to send a dry and boring email :
let str = "mailto:[email protected][email protected]&subject=Greetings%20from%20Cupertino!&body=Wish%20you%20were%20here!"
let url = NSURL(string: str)
UIApplication.sharedApplication().openURL(url)
Butterfly provides an elegant way to present users' feedback as easy as possible.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Butterfly', '~> 0.3.13'
$ git submodule add https://github.com/wongzigii/Butterfly.git
Butterfly
folder, and drag Butterfly.xcodeproj
into the file navigator of your app project, under your app project.import Butterfly
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
ButterflyManager.sharedManager.startListeningShake()
let uploader = ButterflyFileUploader.sharedUploader
uploader.setValue( "sample", forParameter: "folderName" )
uploader.setServerURLString("https://myserver.com/foo")
return true
}
ButterflyViewController
delegate method invoked when send button pressed. You may want to implement this method to handle the image. However, in Xcode Version 6.4 (6E35b) with Swift 2.0, there currently seems to be no way to call static (class) methods defined in a protocol (in pure Swift).
Considering this issue, Butterfly included the ButterflyFileUploader
to handle uploading stuff in v0.3.13. The ButterflyFileUploader
class is an encapsulation under Alamofire 's upload API.
func ButterflyViewControllerDidPressedSendButton(drawView: ButterflyDrawView?) {
if let image = imageWillUpload {
let data: UIImage = image
ButterflyFileUploader.sharedUploader.addFileData( UIImageJPEGRepresentation(data,0.8), withName: currentDate(), withMimeType: "image/jpeg" )
}
ButterflyFileUploader.sharedUploader.upload()
print("ButterflyViewController 's delegate method [-ButterflyViewControllerDidEndReporting] invoked\n")
}
SereverURLString
// @discussion Make sure your serverURLString is valid before a further application.
// Call `setServerURLString` to replace the default "http://myserver.com/uploadFile" with your own's.
public var serverURLString: String? = "http://myserver.com/uploadFile"
///
/// Set uploader 's server URL
///
/// @param URL The server URL.
///
public func setServerURLString( URL: String ) {
serverURLString = URL
}
///
/// Add one file or multiple files with file URL to uploader.
///
/// @param url The URL of the file whose content will be encoded into the multipart form data.
///
/// @param name The name to associate with the file content in the `Content-Disposition` HTTP header.
///
/// @param mimeType The MIME type to associate with the data in the `Content-Type` HTTP header.
///
public func addFileURL( url: NSURL, withName name: String, withMimeType mimeType: String? = nil ) {
files.append( ButterflyFileUploadInfo( name: name, withFileURL: url, withMimeType: mimeType ) )
}
///
/// Add one file or multiple files with NSData to uploader.
///
/// @param data The data to encode into the multipart form data.
///
/// @param name The name to associate with the file content in the `Content-Disposition` HTTP header.
///
/// @param mimeType The MIME type to associate with the data in the `Content-Type` HTTP header.
///
public func addFileData( data: NSData, withName name: String, withMimeType mimeType: String = "application/octet-stream" ) {
files.append( ButterflyFileUploadInfo( name: name, withData: data, withMimeType: mimeType ) )
}
For further information, please check out ButterflyFileUploader.swift.
Butterfly is under MIT LICENCE, see the LICENCE file for more info.