This is the official ClickSend SDK. Documentation can be found here.
- Sign Up for a free ClickSend account.
- Copy your API key from the API Credentials area.
You can integrate ClicksendSwift into your project manually.
- Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
Open Terminal
git init
- Add ClickSend-swift as a git submodule by running the following command: git submodule add https://github.com/ClickSend/clicksend-swift.git
- Next, go inside the submodule directory "clicksend-swift" and Drag "ClickSendClient" folder inside your project
- Lastly, Install Alamofire using Cocoapods
- CocoapodsCocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:
- Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
- Open Terminal
pod init
- Podfile will be generated and inside that Podfile add
- pod 'Alamofire', '~> 4.9.1' and save
- Go back to Terminal and run
pod install
- After installing Alamofire sing cocoapods, make sure to Open the Project using "project_name.xcworkspace"
- CocoapodsCocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:
- Congrats, You are good to go!
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile: pod 'ClickSendSwift'
Documentation for our SDK and REST API can be found here.
Please follow the installation procedure and then run the following code:
import Alamofire
if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") {
ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
}
let message1 = SmsMessage(
body: "Chocolate bar icing icing oat cake carrot cake jelly cotton MWEvciEPIr.",
to: "+0451111111",
source: "swift"
)
let message2 = SmsMessage(
body: "Chocolate bar icing icing oat cake carrot cake jelly cotton MWEvciEPIr.",
source: "swift",
listId: 1234
)
let smsCollection = SmsMessageCollection(messages: [message1, message2])
SMSAPI.smsSendPost(smsMessages: smsCollection) { (dataString, error) in
guard let dataString = dataString else {
print(error!)
return
}
if let data = dataString.data(using: String.Encoding.utf8) {
do {
if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
print(dictonary)
} else {
print("bad json")
}
} catch let error as NSError {
print(error)
}
}
}