Add Token API

This commit is contained in:
kevinzhow
2015-03-30 07:32:11 +08:00
parent 3cdca83ca6
commit f12c3c20d7
4 changed files with 49 additions and 0 deletions
+4
View File
@@ -14,6 +14,7 @@
0A8F54B81AB67D11004AD60E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A8F54B71AB67D11004AD60E /* Images.xcassets */; };
0A8F54BB1AB67D11004AD60E /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0A8F54B91AB67D11004AD60E /* LaunchScreen.xib */; };
0A8F54C71AB67D11004AD60E /* YepTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8F54C61AB67D11004AD60E /* YepTests.swift */; };
0A944C251AC8BB2F00037A06 /* YepStorageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A944C241AC8BB2F00037A06 /* YepStorageService.swift */; };
0AD7EA5E1AC3ED1200617758 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD7EA5D1AC3ED1200617758 /* CFNetwork.framework */; };
0AD7EA601AC3ED1900617758 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD7EA5F1AC3ED1900617758 /* CoreFoundation.framework */; };
0AD7EA621AC3ED2100617758 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD7EA611AC3ED2100617758 /* CoreTelephony.framework */; };
@@ -99,6 +100,7 @@
0A8F54C01AB67D11004AD60E /* YepTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YepTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0A8F54C51AB67D11004AD60E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0A8F54C61AB67D11004AD60E /* YepTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YepTests.swift; sourceTree = "<group>"; };
0A944C241AC8BB2F00037A06 /* YepStorageService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepStorageService.swift; path = Services/YepStorageService.swift; sourceTree = "<group>"; };
0AD7EA511AC3EA6F00617758 /* JPushSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JPushSDK.framework; path = "Pods/../build/Debug-iphoneos/Pods/JPushSDK.framework"; sourceTree = "<group>"; };
0AD7EA581AC3EAF300617758 /* Yep-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Yep-Bridging-Header.h"; sourceTree = "<group>"; };
0AD7EA5B1AC3ECD700617758 /* libPushSDK-1.8.3.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPushSDK-1.8.3.a"; path = "Yep/lib/libPushSDK-1.8.3.a"; sourceTree = "<group>"; };
@@ -431,6 +433,7 @@
502AE5281AB81076005BD199 /* YepService.swift */,
50E114F81ABC137A00F13000 /* YepServiceSync.swift */,
5076C5691AC46B9F00B22952 /* FayeService.swift */,
0A944C241AC8BB2F00037A06 /* YepStorageService.swift */,
);
name = Services;
sourceTree = "<group>";
@@ -832,6 +835,7 @@
503315A01AC126100008A209 /* MessageToolbar.swift in Sources */,
502AE5531AB93215005BD199 /* ProfileFooterCell.swift in Sources */,
0A5D83991AC5D91E000045BF /* ContactsSearchTableViewController.swift in Sources */,
0A944C251AC8BB2F00037A06 /* YepStorageService.swift in Sources */,
5023DE521AB6C51300B3EE96 /* CGRect+Yep.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
+28
View File
@@ -0,0 +1,28 @@
//
// YepStorageService.swift
// Yep
//
// Created by kevinzhow on 15/3/30.
// Copyright (c) 2015 Catch Inc. All rights reserved.
//
import Foundation
func uploadFileToAWSS3(fileUrl: NSURL) -> String {
return ""
}
func requestAWSS3UploadForm(#failureHandler: ((Reason, String?) -> ())?, #completion: JSONDictionary -> Void) {
let parse: JSONDictionary -> JSONDictionary? = { data in
return data
}
let resource = authJsonResource(path: "/api/v1/attachments/s3_upload_public_form_fields", method: .GET, requestParameters:[:], parse: parse)
if let failureHandler = failureHandler {
apiRequest({_ in}, baseURL, resource, failureHandler, completion)
} else {
apiRequest({_ in}, baseURL, resource, defaultFailureHandler, completion)
}
}
@@ -137,6 +137,14 @@ class ConversationViewController: UIViewController {
})
}
}
messageToolbar.voiceSendAction = { messageToolbar in
requestAWSS3UploadForm(failureHandler: { (reason, error) in
println("\(error)")
}, completion: { token in
println("Got S3 token is \(token)")
})
}
}
override func viewDidLayoutSubviews() {
@@ -31,6 +31,8 @@ class MessageToolbar: UIToolbar {
}
var textSendAction: ((messageToolBar: MessageToolbar) -> ())?
var voiceSendAction: ((messageToolBar: MessageToolbar) -> ())?
lazy var cameraButton: UIButton = {
let button = UIButton()
@@ -51,6 +53,7 @@ class MessageToolbar: UIToolbar {
let button = UIButton()
button.setImage(UIImage(named: "item_mic"), forState: .Normal)
button.tintColor = UIColor.yepTintColor()
button.addTarget(self, action: "trySendVoiceMessage", forControlEvents: UIControlEvents.TouchUpInside)
return button
}()
@@ -127,6 +130,12 @@ class MessageToolbar: UIToolbar {
textSendAction(messageToolBar: self)
}
}
func trySendVoiceMessage() {
if let textSendAction = voiceSendAction {
textSendAction(messageToolBar: self)
}
}
}
// MARK: UITextFieldDelegate