CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

SendAnywhereSDK 4.0.14

SendAnywhereSDK 4.0.14

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2017

Maintained by Park, doyoung.



The simplest way to Send files Anywhere

Prequisites

Please issue your API key from following link first: https://send-anywhere.com/web/page/api

Podfile

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'SendAnywhereSDK'
end

Then, run the following command:

$ pod install

Requirements

Minimum iOS Target iOS 8

Troubleshooting

If you have any problem or questions with Send Anywhere iOS SDK, please create new issue(https://github.com/estmob/SendAnywhere-iOS-UI-SDK/issues) or contact to our customer center(https://send-anywhere.zendesk.com).

Usage

First look at the source code of the provided demo.

Initialization

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        SendAnywhere.withKey("INPUT_YOUR_API_KEY")
        return true
}

Show a Send file UI.

do {
    let viewController = try sa_showSendView(withFiles: [fileURL])
} catch let error {

}

Show a Receive file UI.

do {
    let viewController = try sa_showReceiveView()
} catch let error {

}

If you want to download file of specific type.

// If you want to download files of document type.
SendAnywhere.sharedInstance().downloadFileFilter = [.document]

// If you want to download files of image type.
SendAnywhere.sharedInstance().downloadFileFilter = [.image]

// If you want to download files of audio type.
SendAnywhere.sharedInstance().downloadFileFilter = [.audio]

// If you want to download files of media type.
SendAnywhere.sharedInstance().downloadFileFilter = [.image, .video, .audio]

// If you want to download files of custom file pattern.
SendAnywhere.sharedInstance().customFilePattern = "((.+)(\\.(?i)(jpg|jpeg|png|gif))$)"

Send files without UI.

if let fileInfo = SAFileInfo(fileName: <fileName>, path: <filePath>, size: <fileSize>, time: <fileTime>, data: <fileData> or nil) {
    if let command = SASendCommand.makeInstance() {
        command.setParamWith([fileInfo], mode: PAPRIKA_TRANSFER_DIRECT)
        command.addPrepareObserver(<observer>)
        command.execute(completion: nil)
    }    
}

Receive files without UI.

key : 6 digit (ex. 348477)

if let command = SAReceiveCommand.makeInstance() {
    command.transferType = .receive
    command.addErrorObserver(<observer>)
    command.addPrepareObserver(<observer>)
    command.addNotifyObserver(<observer>)
    command.execute(withKey: key)
}

Transfer notification delegate.

Delegate description
SACommandPrepareDelegate update authtoken, update device id
SACommandNotifyDelegate command start, finish
SACommandErrorDelegate command error
SATransferPrepareDelegate fileListUpdated,keyUpdated etc
SATransferNotifyDelegate transfer start, progress, finish etc
SATransferErrorDelegate transfer error
SAReceiveErrorDelegate receive error (key not exists, no disk space etc)

Global notification delegate.

public protocol SAGlobalCommandNotifyDelegate : NSObjectProtocol {

    optional public func willGlobalCommandStart(_ sender: SACommand!)

    optional public func didGlobalCommandFinish(_ sender: SACommand!)

    optional public func didGlobalTransferFileListUpdated(_ sender: SATransferCommand!)

    optional public func willGlobalTransferStart(_ sender: SATransferCommand!)

    optional public func willGlobalTransferFileStart(_ sender: SATransferCommand!)

    optional public func didGlobalTransferFileFinish(_ sender: SATransferCommand!, fileIndex: Int, filePath: String!)

    optional public func didGlobalTransferFinish(_ sender: SATransferCommand!)

    optional public func didGlobalTransferError(_ sender: SATransferCommand!)
}

License

SendAnywhereSDK is available under the MIT license. See the LICENSE file for more info.