├── ChatSecurePushExample
├── .gitignore
├── ChatSecurePushExample.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── xcshareddata
│ │ └── xcschemes
│ │ │ └── ChatSecurePushExample.xcscheme
│ └── project.pbxproj
├── ChatSecurePushExampleTests
│ ├── ChatSecurePushExampleTests-header.h
│ ├── TestObjects.swift
│ ├── Info.plist
│ ├── URLMockSetup.swift
│ └── ChatSecurePushExampleTests.swift
├── ChatSecurePushExample.xcworkspace
│ ├── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
│ └── contents.xcworkspacedata
├── Podfile
├── Podfile.lock
└── ChatSecurePushExample
│ ├── ViewController.swift
│ ├── Info.plist
│ ├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── AccountDetailViewController.swift
│ ├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
│ └── AppDelegate.swift
├── Gemfile
├── .travis.yml
├── .gitignore
├── ChatSecurePush-SDK
├── NSURLSessionTaskDelegate.swift
├── Error.swift
├── Account.swift
├── Message.swift
├── AccountEndpoint.swift
├── DeviceEndpoint.swift
├── Serializer.swift
├── MessageEndpoint.swift
├── TokenEndpoint.swift
├── Endpoint.swift
├── Token.swift
├── Device.swift
├── Deserializer.swift
└── Client.swift
├── ChatSecure-Push-iOS.podspec
├── Gemfile.lock
├── README.md
└── LICENSE
/ChatSecurePushExample/.gitignore:
--------------------------------------------------------------------------------
1 | /Pods
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | gem 'cocoapods'
4 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExampleTests/ChatSecurePushExampleTests-header.h:
--------------------------------------------------------------------------------
1 | //
2 | // ChatSecurePushExampleTests-header.h
3 | // ChatSecurePushExample
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | // Copyright (c) 2015 David Chiles. All rights reserved.
7 | //
8 |
9 | #import
10 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 | osx_image: xcode10.2
3 | cache: cocoapods
4 |
5 | script:
6 | - pod update --project-directory=ChatSecurePushExample
7 | - travis_retry xcodebuild -workspace ChatSecurePushExample/ChatSecurePushExample.xcworkspace -scheme ChatSecurePushExample -sdk iphonesimulator -destination "OS=12.2,name=iPhone 8 Plus" test | xcpretty -c
8 | - pod lib lint --allow-warnings --swift-version=5.0
--------------------------------------------------------------------------------
/ChatSecurePushExample/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | platform :ios, '8.0'
3 |
4 | use_frameworks!
5 |
6 | def default_pod
7 | pod 'ChatSecure-Push-iOS', :path => '../ChatSecure-Push-iOS.podspec'
8 | end
9 |
10 | target 'ChatSecurePushExample' do
11 | default_pod
12 | end
13 |
14 | target 'ChatSecurePushExampleTests' do
15 | platform :ios, '8.0'
16 | default_pod
17 | pod 'URLMock', '~> 1.3'
18 | end
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | #Pods/
27 |
28 | .DS_Store
29 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExampleTests/TestObjects.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TestObjects.swift
3 | // ChatSecurePushExample
4 | //
5 | // Created by David Chiles on 9/2/15.
6 | // Copyright (c) 2015 David Chiles. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import ChatSecure_Push_iOS
11 |
12 | func uuid() -> String {
13 | return UUID().uuidString
14 | }
15 |
16 | extension Token {
17 | class func randomToken() -> Token {
18 | let kindInt = Int(arc4random_uniform(1) + 1)
19 | let kind = DeviceKind(rawValue: kindInt) ?? DeviceKind.unknown
20 | return Token(tokenString: uuid(), type: kind, deviceID: uuid())
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/NSURLSessionTaskDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NSURLSessionTaskDelegate.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 3/11/16.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 | open class URLSessionDelegate:NSObject, URLSessionDataDelegate {
12 |
13 | /// Handle redirects
14 | open func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
15 | guard let req = (task.originalRequest as NSURLRequest?)?.mutableCopy() as? NSMutableURLRequest else {
16 | completionHandler(request)
17 | return
18 | }
19 |
20 | req.url = request.url
21 | completionHandler(req as URLRequest)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - ChatSecure-Push-iOS (1.0)
3 | - SOCKit (1.1)
4 | - URLMock (1.3.4):
5 | - URLMock/Core (= 1.3.4)
6 | - URLMock/SubclassResponsibility (= 1.3.4)
7 | - URLMock/TestHelpers (= 1.3.4)
8 | - URLMock/Core (1.3.4):
9 | - SOCKit (~> 1.1)
10 | - URLMock/SubclassResponsibility (1.3.4):
11 | - URLMock/TestHelpers
12 | - URLMock/TestHelpers (1.3.4)
13 |
14 | DEPENDENCIES:
15 | - ChatSecure-Push-iOS (from `../ChatSecure-Push-iOS.podspec`)
16 | - URLMock (~> 1.3)
17 |
18 | SPEC REPOS:
19 | https://github.com/cocoapods/specs.git:
20 | - SOCKit
21 | - URLMock
22 |
23 | EXTERNAL SOURCES:
24 | ChatSecure-Push-iOS:
25 | :path: "../ChatSecure-Push-iOS.podspec"
26 |
27 | SPEC CHECKSUMS:
28 | ChatSecure-Push-iOS: 8e336b0f94f80fae22e734e592c14de6ecf8d091
29 | SOCKit: c7376ac262bea9115b8f749358f762522a47d392
30 | URLMock: 714b802836ab505356118991c167327eed4c7e59
31 |
32 | PODFILE CHECKSUM: 9b6bb64e4b69301c018057fde084df58d9f932e6
33 |
34 | COCOAPODS: 1.6.1
35 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Error.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Error.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 3/9/16.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | public enum ErrorDomain: String {
13 | case chatsecurePush = "org.chatsecure.push"
14 | }
15 |
16 | ///Enum of all the status codes used in the SDK for erros
17 | public enum ErrorStatusCode: NSInteger {
18 | case noData = 601
19 | case badJSON = 602
20 | case noTokenType = 603
21 | case missingURL = 604
22 | case creatingRequest = 605
23 | }
24 |
25 | extension NSError {
26 |
27 | /**
28 | Returns an default NSError using the correct domain and enum status code
29 |
30 | - Parameter code: The status code
31 | - Parameter userInfo: The userinfo dictionary including kyes NSLocalized string
32 |
33 | - Returns: A ChatSecure push error
34 | */
35 | public class func error(_ code:ErrorStatusCode, userInfo: [String: Any]) -> NSError {
36 | return NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: code.rawValue, userInfo: userInfo)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // ChatSecurePushExample
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | // Copyright (c) 2015 David Chiles. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import ChatSecure_Push_iOS
11 |
12 | class ViewController: UIViewController, UITextFieldDelegate {
13 |
14 | @IBOutlet var usernameTextField: UITextField!
15 | @IBOutlet var passwordTextField: UITextField!
16 |
17 | override func viewDidLoad() {
18 | super.viewDidLoad()
19 | self.usernameTextField.delegate = self
20 | self.passwordTextField.delegate = self
21 | }
22 |
23 | func textFieldShouldReturn(_ textField: UITextField) -> Bool {
24 | textField.resignFirstResponder()
25 | return false
26 | }
27 |
28 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
29 | if let vc = segue.destination as? AccountDetailViewController {
30 | if let username = self.usernameTextField.text {
31 | vc.account = Account(username:username)
32 | vc.password = self.passwordTextField.text
33 | }
34 |
35 | }
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Account.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Account.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | @objc open class Account: NSObject, NSCoding, NSCopying {
13 | @objc public let username: String
14 | @objc open var token: String?
15 | @objc open var email: String?
16 |
17 | @objc public init (username: String) {
18 | self.username = username
19 | }
20 |
21 | public required init?(coder aDecoder: NSCoder) {
22 | if let username = aDecoder.decodeObject(forKey: "username") as? String {
23 | self.username = username
24 | } else {
25 | self.username = ""
26 | }
27 | self.token = aDecoder.decodeObject(forKey: "token") as? String
28 | self.email = aDecoder.decodeObject(forKey: "email") as? String
29 | }
30 |
31 | open func encode(with aCoder: NSCoder) {
32 | aCoder.encode(self.username, forKey: "username")
33 | aCoder.encode(self.token, forKey: "token")
34 | aCoder.encode(self.email, forKey: "email")
35 | }
36 |
37 | open func copy(with zone: NSZone?) -> Any {
38 | let newAccount = Account(username: self.username)
39 | newAccount.token = self.token
40 | newAccount.email = self.email
41 | return newAccount
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Message.swift:
--------------------------------------------------------------------------------
1 | //
2 | // File.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | @objc open class Message: NSObject, NSCoding, NSCopying {
13 | /// The token string
14 | @objc open var token: String
15 | @objc open var url: URL?
16 |
17 | /// Data needs to be a dictionary that can be serialized as JSON
18 | @objc open var data: [String:Any]?
19 |
20 | @objc public init(token: String, url:URL?, data: [String:Any]?){
21 | self.token = token
22 | self.url = url
23 | self.data = data
24 | }
25 |
26 | public required init?(coder aDecoder: NSCoder) {
27 | self.token = ""
28 | super.init()
29 |
30 | guard let token = aDecoder.decodeObject(forKey: "token") as? String else {
31 | return nil
32 | }
33 | self.url = aDecoder.decodeObject(forKey: "url") as? URL
34 | self.data = aDecoder.decodeObject(forKey: "data") as? [String:AnyObject]
35 | self.token = token
36 | }
37 |
38 | open func encode(with aCoder: NSCoder) {
39 | aCoder.encode(self.token, forKey: "token")
40 | aCoder.encode(self.data, forKey: "data")
41 | aCoder.encode(self.url, forKey: "url")
42 | }
43 |
44 | open func copy(with zone: NSZone?) -> Any {
45 | return Message(token: self.token, url: self.url, data: self.data)
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/AccountEndpoint.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AccountEndpoint.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 8/31/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | class AccountEnpoint: APIEndpoint {
13 |
14 | func postRequest(_ username: String, password: String, email: String?) throws -> URLRequest {
15 |
16 | var parameters = [
17 | jsonKeys.username.rawValue : username,
18 | jsonKeys.password.rawValue : password,
19 | ]
20 | if let email = email {
21 | parameters[jsonKeys.email.rawValue] = email
22 | }
23 | return try self.request(.post, endpoint:Endpoint.accounts.rawValue, jsonDictionary:parameters)
24 | }
25 |
26 | func deleteRequest(_ account: Account) throws -> URLRequest {
27 | let endpoint = "\(Endpoint.accounts.rawValue)/\(account.username)"
28 | return try self.request(.delete, endpoint:endpoint, jsonDictionary:nil)
29 | }
30 |
31 | func accountFromResponse(_ responseData: Data?, response: URLResponse?, error: NSError?) throws -> Account {
32 |
33 | try self.handleError(responseData, response: response, error: error)
34 |
35 | guard let data = responseData else {
36 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.noData.rawValue, userInfo: nil)
37 | }
38 |
39 | return try Deserializer.account(withData: data)
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ChatSecure-Push-iOS.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod spec lint ChatSecure-Push-iOS.podspec' to ensure this is a
3 | # valid spec and to remove all comments including this before submitting the spec.
4 | #
5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
7 | #
8 |
9 | Pod::Spec.new do |s|
10 |
11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
12 | #
13 | # These will help people to find your library, and whilst it
14 | # can feel like a chore to fill in it's definitely to your advantage. The
15 | # summary should be tweet-length, and the description more in depth.
16 | #
17 |
18 | s.name = "ChatSecure-Push-iOS"
19 | s.version = "1.1"
20 | s.summary = "The iOS SDK for ChatSecure-Push-Server"
21 |
22 | s.description = <<-DESC
23 | A Swift way to interact with the ChatSecure-Push-Server API.
24 |
25 | DESC
26 |
27 | s.homepage = "https://github.com/ChatSecure/ChatSecure-Push-iOS"
28 | s.license = { :type => "GNU GPL v3", :file => "LICENSE" }
29 | s.author = "ChatSecure"
30 | s.social_media_url = "http://twitter.com/ChatSecure"
31 |
32 | s.ios.deployment_target = "8.0"
33 | s.osx.deployment_target = "10.9"
34 | s.requires_arc = true
35 | s.source = { :git => "https://github.com/ChatSecure/ChatSecure-Push-iOS.git", :tag => s.version.to_s }
36 |
37 | s.source_files = "Classes", "ChatSecurePush-SDK/*.swift"
38 | end
39 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/DeviceEndpoint.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DeviceClient.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 8/31/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 | class APNSDeviceEndpoint: APIEndpoint {
12 |
13 | func postRequest(_ APNSToken: String, name: String?, deviceID: String?, serverID: String?) throws -> URLRequest {
14 | var parameters = [
15 | jsonKeys.registrationID.rawValue: APNSToken,
16 | ]
17 |
18 | parameters[jsonKeys.name.rawValue] = name
19 | parameters[jsonKeys.deviceID.rawValue] = deviceID
20 |
21 | var endpoint = Endpoint.apns.rawValue
22 | if let id = serverID {
23 | endpoint = "\(endpoint)/\(id)"
24 | }
25 |
26 | return try self.request(Method.post, endpoint: endpoint, jsonDictionary: parameters)
27 | }
28 |
29 | func putRequest(_ APNSToken: String, name: String?, deviceID: String?, serverID: String?) throws -> URLRequest {
30 | var request = try self.postRequest(APNSToken, name: name, deviceID: deviceID, serverID: serverID)
31 | request.httpMethod = Method.put.rawValue
32 | return request
33 | }
34 |
35 | func deviceFromResponse(_ responseData: Data?, response: URLResponse?, error: Error?) throws -> Device {
36 | try self.handleError(responseData, response: response, error: error)
37 |
38 | guard let data = responseData else {
39 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.noData.rawValue, userInfo: nil)
40 | }
41 |
42 | return try Deserializer.device(data, kind: .iOS)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Serializer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Deserializer.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 7/14/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | open class Serializer {
13 |
14 | open class func jsonValue(_ object:AnyObject) throws -> [String:AnyObject]? {
15 |
16 | var json: [String: AnyObject]? = nil
17 |
18 | if let message = object as? Message {
19 | json = [jsonKeys.token.rawValue: message.token as AnyObject]
20 | if let data = message.data {
21 | json?.updateValue(data as AnyObject, forKey: jsonKeys.dataKey.rawValue)
22 | }
23 | }
24 |
25 | if let token = object as? Token {
26 | json = [jsonKeys.token.rawValue: token.tokenString as AnyObject]
27 |
28 | if let name = token.name {
29 | json?.updateValue(name as AnyObject, forKey: jsonKeys.name.rawValue)
30 | }
31 |
32 |
33 |
34 | if let deviceID = token.registrationID {
35 | switch token.type {
36 | case .iOS:
37 | json?.updateValue(deviceID as AnyObject, forKey: jsonKeys.apnsDeviceKey.rawValue)
38 | case .android:
39 | json?.updateValue(deviceID as AnyObject, forKey: jsonKeys.gcmDeviceKey.rawValue)
40 | default:
41 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.noTokenType.rawValue, userInfo: nil)
42 | }
43 |
44 | }
45 | }
46 |
47 | return json
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/MessageEndpoint.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MessageEndpoint.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 8/31/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | class MessageEndpoint:APIEndpoint {
13 |
14 | /**
15 | Creates a mutable post reqeust from a message object. If there is an url in the message that is used instead of the base URL.
16 |
17 | - Parameter message: The message to be serialized and add to the mutableURLRequest
18 | - Returns: A mutableURLRequest that can be used to post to the message endpoint
19 | */
20 | func postRequest(_ message:Message) throws -> URLRequest {
21 | let jsonDictionary = try Serializer.jsonValue(message)
22 |
23 | if let url = message.url {
24 | return try APIEndpoint.request(Method.post.rawValue, URL: url, jsonDictionary: jsonDictionary)
25 | } else {
26 | return try self.request(.post, endpoint: Endpoint.messages.rawValue, jsonDictionary: jsonDictionary)
27 | }
28 | }
29 |
30 | func messageFromResponse(_ responseData: Data?, response: URLResponse?, error: Error?) throws -> Message {
31 | try self.handleError(responseData, response: response, error: error)
32 |
33 | guard let data = responseData else {
34 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.noData.rawValue, userInfo: nil)
35 | }
36 |
37 | guard let url = response?.url else {
38 | throw NSError.error(.missingURL, userInfo: [NSLocalizedDescriptionKey:"Required to have a url inorder to create a Message object"])
39 | }
40 |
41 | return try Deserializer.message(data, url: url)
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UIBackgroundModes
26 |
27 | remote-notification
28 |
29 | UILaunchStoryboardName
30 | LaunchScreen
31 | UIMainStoryboardFile
32 | Main
33 | UIRequiredDeviceCapabilities
34 |
35 | armv7
36 |
37 | UISupportedInterfaceOrientations
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationLandscapeLeft
41 | UIInterfaceOrientationLandscapeRight
42 |
43 | UISupportedInterfaceOrientations~ipad
44 |
45 | UIInterfaceOrientationPortrait
46 | UIInterfaceOrientationPortraitUpsideDown
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 | NSAppTransportSecurity
51 |
52 | NSAllowsArbitraryLoads
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.0)
5 | activesupport (4.2.11.1)
6 | i18n (~> 0.7)
7 | minitest (~> 5.1)
8 | thread_safe (~> 0.3, >= 0.3.4)
9 | tzinfo (~> 1.1)
10 | atomos (0.1.3)
11 | claide (1.0.2)
12 | cocoapods (1.6.1)
13 | activesupport (>= 4.0.2, < 5)
14 | claide (>= 1.0.2, < 2.0)
15 | cocoapods-core (= 1.6.1)
16 | cocoapods-deintegrate (>= 1.0.2, < 2.0)
17 | cocoapods-downloader (>= 1.2.2, < 2.0)
18 | cocoapods-plugins (>= 1.0.0, < 2.0)
19 | cocoapods-search (>= 1.0.0, < 2.0)
20 | cocoapods-stats (>= 1.0.0, < 2.0)
21 | cocoapods-trunk (>= 1.3.1, < 2.0)
22 | cocoapods-try (>= 1.1.0, < 2.0)
23 | colored2 (~> 3.1)
24 | escape (~> 0.0.4)
25 | fourflusher (>= 2.2.0, < 3.0)
26 | gh_inspector (~> 1.0)
27 | molinillo (~> 0.6.6)
28 | nap (~> 1.0)
29 | ruby-macho (~> 1.4)
30 | xcodeproj (>= 1.8.1, < 2.0)
31 | cocoapods-core (1.6.1)
32 | activesupport (>= 4.0.2, < 6)
33 | fuzzy_match (~> 2.0.4)
34 | nap (~> 1.0)
35 | cocoapods-deintegrate (1.0.4)
36 | cocoapods-downloader (1.2.2)
37 | cocoapods-plugins (1.0.0)
38 | nap
39 | cocoapods-search (1.0.0)
40 | cocoapods-stats (1.1.0)
41 | cocoapods-trunk (1.3.1)
42 | nap (>= 0.8, < 2.0)
43 | netrc (~> 0.11)
44 | cocoapods-try (1.1.0)
45 | colored2 (3.1.2)
46 | concurrent-ruby (1.1.5)
47 | escape (0.0.4)
48 | fourflusher (2.2.0)
49 | fuzzy_match (2.0.4)
50 | gh_inspector (1.1.3)
51 | i18n (0.9.5)
52 | concurrent-ruby (~> 1.0)
53 | minitest (5.11.3)
54 | molinillo (0.6.6)
55 | nanaimo (0.2.6)
56 | nap (1.1.0)
57 | netrc (0.11.0)
58 | ruby-macho (1.4.0)
59 | thread_safe (0.3.6)
60 | tzinfo (1.2.5)
61 | thread_safe (~> 0.1)
62 | xcodeproj (1.8.2)
63 | CFPropertyList (>= 2.3.3, < 4.0)
64 | atomos (~> 0.1.3)
65 | claide (>= 1.0.2, < 2.0)
66 | colored2 (~> 3.1)
67 | nanaimo (~> 0.2.6)
68 |
69 | PLATFORMS
70 | ruby
71 |
72 | DEPENDENCIES
73 | cocoapods
74 |
75 | BUNDLED WITH
76 | 1.17.2
77 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/TokenEndpoint.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TokenEndpoint.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 8/31/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | class TokenEndpoint: APIEndpoint {
13 | func postRequest(_ id:String ,name:String?) throws -> URLRequest {
14 | var parameters = [
15 | jsonKeys.apnsDeviceKey.rawValue: id
16 | ]
17 | parameters[jsonKeys.name.rawValue] = name
18 |
19 | let request = try self.request(.post, endpoint: Endpoint.tokens.rawValue, jsonDictionary: parameters)
20 | return request
21 | }
22 |
23 | func getRequest(_ id:String?) throws -> URLRequest {
24 | var request = try self.request(.get, endpoint: Endpoint.tokens.rawValue, jsonDictionary: nil)
25 | if let tokenID = id {
26 | request.url = request.url?.appendingPathComponent(tokenID)
27 | }
28 |
29 | return request
30 | }
31 |
32 | func deleteRequest(_ id:String) throws -> URLRequest {
33 | var request = try self.request(.delete, endpoint: Endpoint.tokens.rawValue, jsonDictionary: nil)
34 | request.url = request.url?.appendingPathComponent("\(id)/")
35 | return request
36 | }
37 |
38 | func tokenFromResponse(_ responseData: Data?, response: URLResponse?, error: Error?) throws -> Token {
39 | try self.handleError(responseData, response: response, error: error)
40 |
41 | guard let data = responseData else {
42 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.noData.rawValue, userInfo: nil)
43 | }
44 |
45 | return try Deserializer.token(data)
46 | }
47 |
48 | func tokensFromResponse(_ responseData: Data?, response: URLResponse?, error: Error?) throws -> [Token] {
49 | try self.handleError(responseData, response: response, error: error)
50 |
51 | guard let data = responseData else {
52 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.noData.rawValue, userInfo: nil)
53 | }
54 |
55 | return try Deserializer.tokens(data)
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ChatSecure-Push-iOS
2 | The iOS SDK for [ChatSecure-Push-Server](https://github.com/ChatSecure/ChatSecure-Push-Server).
3 |
4 | ## Getting Started
5 |
6 | ### Install
7 | ```ruby
8 | pod 'ChatSecure-Push-iOS', :git => 'https://github.com/ChatSecure/ChatSecure-Push-iOS'
9 | ```
10 |
11 | ### Usage
12 |
13 | ### 1. Setup
14 | If it's the first launch and there is no account.
15 | ```swift
16 | let client = Client(baseUrl: NSURL(string: urlString)!, urlSessionConfiguration: NSURLSessionConfiguration.defaultSessionConfiguration(), account: nil)
17 | ```
18 | Or if you already have an account. You'll need to store the `username` and `token` to make API requests.
19 | ```swfit
20 | let client = Client(baseUrl: NSURL(string: urlString)!, urlSessionConfiguration: NSURLSessionConfiguration.defaultSessionConfiguration(), account: account)
21 | ```
22 |
23 | ### 2. Create account
24 | ```swift
25 | client.registerNewUser(username, password: password, email: nil, completion: { (account, error) -> Void in
26 | //Save account here
27 | })
28 | ```
29 |
30 | ### 3. Register new device
31 | In order to register a new device first get an APNS token.
32 |
33 | ```swift
34 | var settings = UIUserNotificationSettings(forTypes: (UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert), categories: nil)
35 | application.registerUserNotificationSettings(settings)
36 | ```
37 | Once you've recieved the token in the `AppDelegate`.
38 |
39 | ```swift
40 | self.client.registerDevice(apnsToken, name: "New device name", deviceID: nil, completion: { (device, error) -> Void in
41 | //Save device here
42 | })
43 | ```
44 |
45 | ### 4. Get whitelist token to hand out to a friend
46 | ```swift
47 | self.client.createToken(apnsToken, name: "New token", completion: { (token, error) -> Void in
48 | //Save and send to friend
49 | })
50 | ```
51 |
52 | ### 5. Send a push message to a friend
53 |
54 | Once you receive a `token` from a friend you can send them a push message.
55 |
56 | `data` needs to be a dictionary that is serializable to JSON.
57 |
58 | ```swift
59 | var message = Message(token: token, data: nil)
60 | self.client.sendMessage(message, completion: { (msg, error) -> Void in
61 | println("Message: \(msg)")
62 | })
63 | ```
64 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Endpoint.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Endpoint.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 8/31/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | class APIEndpoint {
13 |
14 | var baseURL: URL
15 | var token: String?
16 |
17 | init (baseUrl: URL) {
18 | self.baseURL = baseUrl
19 | }
20 |
21 | func request(_ method: Method, endpoint: String, jsonDictionary:[String: Any]?) throws -> URLRequest {
22 |
23 | return try APIEndpoint.request(method.rawValue, URL: self.url(endpoint), jsonDictionary: jsonDictionary)
24 | }
25 |
26 | func url(_ endPoint: String) -> URL {
27 | return self.baseURL.appendingPathComponent(endPoint+"/")
28 | }
29 |
30 | func handleError(_ data: Data?, response: URLResponse?, error: Error?) throws {
31 |
32 | if let err = error {
33 | throw err
34 | }
35 |
36 | if let httpResponse = response as? HTTPURLResponse {
37 | try self.validate(httpResponse, responseData:data)
38 | }
39 | }
40 |
41 | func validate(_ response: HTTPURLResponse, responseData:Data?) throws {
42 | var acceptable = false
43 | if response.statusCode > 199 && response.statusCode < 300 {
44 | acceptable = true
45 | }
46 |
47 | if(!acceptable) {
48 | var userInfo : [String: Any] = [:]
49 | if let data = responseData {
50 | if let string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) {
51 | userInfo = [NSLocalizedDescriptionKey:string]
52 | }
53 | }
54 |
55 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: response.statusCode, userInfo: userInfo)
56 | }
57 | }
58 |
59 | class func request(_ method: String, URL:Foundation.URL, jsonDictionary:[String:Any]?) throws -> URLRequest {
60 | var request = URLRequest(url: URL)
61 | request.httpMethod = method
62 |
63 | if let json = jsonDictionary {
64 | request.httpBody = try JSONSerialization.data(withJSONObject: json, options: JSONSerialization.WritingOptions())
65 |
66 | if let count = request.httpBody?.count, count > 0 {
67 | request.setValue("application/json", forHTTPHeaderField: "Content-Type")
68 | }
69 | }
70 |
71 | return request
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Token.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Token.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 | private enum TokenCodingSrings:String {
12 | case tokenString = "tokenString"
13 | case registrationID = "registrationID"
14 | case deviceType = "type"
15 | case name = "name"
16 | case expires = "expires"
17 | }
18 |
19 | @objc open class Token: NSObject, NSCoding, NSCopying {
20 | @objc public let tokenString: String
21 | @objc open var expires:Date?
22 | @objc open var registrationID: String?
23 | @objc open var name: String?
24 | @objc open var type:DeviceKind = .unknown
25 |
26 | @objc public init (tokenString: String, type:DeviceKind, deviceID: String?) {
27 | self.tokenString = tokenString
28 | self.registrationID = deviceID
29 | self.type = type
30 | }
31 |
32 | public required init(coder aDecoder: NSCoder) {
33 | if let tokenString = aDecoder.decodeObject(forKey: TokenCodingSrings.tokenString.rawValue) as? String {
34 | self.tokenString = tokenString
35 | } else {
36 | self.tokenString = ""
37 | }
38 |
39 | if let registrationID = aDecoder.decodeObject(forKey: TokenCodingSrings.registrationID.rawValue) as? String {
40 | self.registrationID = registrationID
41 | }
42 |
43 | if let type = DeviceKind(rawValue: aDecoder.decodeInteger(forKey: TokenCodingSrings.deviceType.rawValue)) {
44 | self.type = type
45 | }
46 |
47 | self.name = aDecoder.decodeObject(forKey: TokenCodingSrings.name.rawValue) as? String
48 | self.expires = aDecoder.decodeObject(forKey: TokenCodingSrings.expires.rawValue) as? Date
49 | }
50 |
51 | open func encode(with aCoder: NSCoder) {
52 | aCoder.encode(self.tokenString, forKey: TokenCodingSrings.tokenString.rawValue)
53 | aCoder.encode(self.registrationID, forKey: TokenCodingSrings.registrationID.rawValue)
54 | aCoder.encode(self.name, forKey: TokenCodingSrings.name.rawValue)
55 | aCoder.encode(self.type.rawValue, forKey: TokenCodingSrings.deviceType.rawValue)
56 | aCoder.encode(self.expires, forKey: TokenCodingSrings.expires.rawValue)
57 | }
58 |
59 | open func copy(with zone: NSZone?) -> Any {
60 | let newToken = Token(tokenString: self.tokenString, type: self.type, deviceID: self.registrationID)
61 | newToken.name = self.name
62 | newToken.expires = self.expires
63 | return newToken
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Device.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Device.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 | @objc public enum DeviceKind:Int {
12 | case unknown = 0
13 | case iOS = 1
14 | case android = 2
15 | }
16 |
17 | public extension Data {
18 |
19 | //https://stackoverflow.com/questions/39075043/how-to-convert-data-to-hex-string-in-swift/40089462#40089462
20 | func hexString() -> String {
21 | return map { String(format: "%02hhx", $0) }.joined()
22 | }
23 | }
24 |
25 | @objc open class Device: NSObject, NSCoding, NSCopying {
26 | @objc open var name: String?
27 | @objc open var id: String?
28 | @objc open var deviceID: String?
29 | @objc open var registrationID: String
30 | @objc open var active = true
31 | @objc open var deviceKind = DeviceKind.unknown
32 | @objc public let dateCreated: Date
33 |
34 |
35 |
36 | @objc public init (registrationID: String,dateCreated: Date, name: String?, deviceID: String?, id: String?) {
37 | self.name = name
38 | self.dateCreated = dateCreated
39 | self.registrationID = registrationID
40 | self.deviceID = deviceID
41 | self.id = id
42 | }
43 |
44 | public required init?(coder aDecoder: NSCoder) {
45 | self.name = aDecoder.decodeObject(forKey: "name") as? String
46 | self.id = aDecoder.decodeObject(forKey: "id") as? String
47 | self.deviceID = aDecoder.decodeObject(forKey: "deviceID") as? String
48 | if let registrationID = aDecoder.decodeObject(forKey: "registrationID") as? String {
49 | self.registrationID = registrationID
50 | } else {
51 | self.registrationID = ""
52 | }
53 | self.active = aDecoder.decodeBool(forKey: "active")
54 | if let date = aDecoder.decodeObject(forKey: "dateCreated") as? Date {
55 | self.dateCreated = date
56 | } else {
57 | self.dateCreated = Date()
58 | }
59 | if let deviceKindRawValue = aDecoder.decodeObject(forKey: "deviceKind") as? Int {
60 | if let deviceKind = DeviceKind(rawValue: deviceKindRawValue) {
61 | self.deviceKind = deviceKind
62 | } else {
63 | self.deviceKind = .unknown
64 | }
65 | } else {
66 | self.deviceKind = .unknown
67 | }
68 | }
69 |
70 | open func encode(with aCoder: NSCoder) {
71 | aCoder.encode(self.name, forKey: "name")
72 | aCoder.encode(self.id, forKey: "id")
73 | aCoder.encode(self.deviceID, forKey: "deviceID")
74 | aCoder.encode(self.registrationID, forKey: "registrationID")
75 | aCoder.encode(self.active, forKey: "active")
76 | aCoder.encode(self.dateCreated, forKey: "dateCreated")
77 | aCoder.encode(self.deviceKind.rawValue, forKey: "deviceKind")
78 | }
79 |
80 | open func copy(with zone: NSZone?) -> Any {
81 | let newDevice = Device(registrationID: self.registrationID, dateCreated: self.dateCreated, name: self.name, deviceID: self.deviceID, id: self.deviceID)
82 | newDevice.active = self.active
83 | newDevice.deviceKind = self.deviceKind
84 | return newDevice
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample/AccountDetailViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AccountDetailViewController.swift
3 | // ChatSecurePushExample
4 | //
5 | // Created by David Chiles on 7/21/15.
6 | // Copyright (c) 2015 David Chiles. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import UIKit
11 | import ChatSecure_Push_iOS
12 |
13 | let urlString = "http://10.11.41.112:8001/api/v1/"
14 |
15 | class AccountDetailViewController: UIViewController {
16 |
17 | var account: Account?
18 | var device: Device?
19 | var password: String?
20 |
21 | @IBOutlet var accountStatusLabel: UILabel?
22 | @IBOutlet var messageTokenTextField: UITextField?
23 |
24 |
25 | let client = Client(baseUrl: URL(string: urlString)!, urlSessionConfiguration: URLSessionConfiguration.default, account: nil)
26 |
27 | override func viewDidLoad() {
28 |
29 | if let password = self.password {
30 | if let username = self.account?.username {
31 | self.accountStatusLabel?.text = "Creating Account..."
32 | self.client.registerNewUser(username, password: password, email: nil, completion: { (account, error) -> Void in
33 |
34 |
35 | if let newAccount = account {
36 | DispatchQueue.main.async(execute: { () -> Void in
37 | self.accountStatusLabel?.text = "Created Account: \(newAccount.username)"
38 | })
39 |
40 | self.account = newAccount
41 | self.client.account = newAccount
42 | if let apnsToken = (UIApplication.shared.delegate as? AppDelegate)?.apnsToken {
43 | self.client.registerDevice(apnsToken, name: "I'm just a test device", deviceID: nil, completion: { (device, error) -> Void in
44 | self.device = device
45 | })
46 | }
47 | }
48 | })
49 | }
50 | }
51 | }
52 |
53 | @IBAction func sendMessageButtonPressed(_ sender: AnyObject?) {
54 | if let token = self.messageTokenTextField?.text {
55 | let message = Message(token: token, url:nil, data: nil)
56 | self.client.sendMessage(message, completion: { (msg, error) -> Void in
57 | print("Message: \(String(describing: msg))")
58 | })
59 | }
60 |
61 | }
62 |
63 | @IBAction func whitelistTokenButtonPressed(_ sender: AnyObject?) {
64 | if let _ = (UIApplication.shared.delegate as? AppDelegate)?.apnsToken {
65 | if let id = self.device?.id {
66 | self.client.createToken(id, name: "I'm just a test token", completion: { (token, error) -> Void in
67 | if let tempToken = token {
68 | print("Token: \(String(describing: token))")
69 | DispatchQueue.main.async(execute: { () -> Void in
70 | let activityVewController = UIActivityViewController(activityItems: [tempToken.tokenString], applicationActivities: nil)
71 | self.present(activityVewController, animated: true, completion: nil)
72 | })
73 | }
74 |
75 |
76 | });
77 | }
78 |
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ChatSecurePushExample
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | // Copyright (c) 2015 David Chiles. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import ChatSecure_Push_iOS
11 |
12 | enum userDefaultsKey: String {
13 | case apnsKey = "apnsKey"
14 | }
15 |
16 | @UIApplicationMain
17 | class AppDelegate: UIResponder, UIApplicationDelegate {
18 |
19 | var window: UIWindow?
20 |
21 | var apnsToken: String?
22 |
23 |
24 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
25 |
26 | let settings = UIUserNotificationSettings(types: ([UIUserNotificationType.badge, UIUserNotificationType.sound, UIUserNotificationType.alert]), categories: nil)
27 | application.registerUserNotificationSettings(settings)
28 | return true
29 | }
30 |
31 | func applicationWillResignActive(_ application: UIApplication) {
32 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
33 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
34 | }
35 |
36 | func applicationDidEnterBackground(_ application: UIApplication) {
37 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
38 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
39 | }
40 |
41 | func applicationWillEnterForeground(_ application: UIApplication) {
42 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
43 | }
44 |
45 | func applicationDidBecomeActive(_ application: UIApplication) {
46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
47 | }
48 |
49 | func applicationWillTerminate(_ application: UIApplication) {
50 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
51 | }
52 |
53 | func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) {
54 | application.registerForRemoteNotifications()
55 | }
56 |
57 | func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
58 | self.apnsToken = deviceToken.hexString()
59 | UserDefaults.standard.set(self.apnsToken, forKey: userDefaultsKey.apnsKey.rawValue)
60 | }
61 |
62 | func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
63 | print("Error: \(error)", terminator: "")
64 | }
65 |
66 | func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
67 | do {
68 | let message = try Deserializer.messageFromPushDictionary(userInfo)
69 | print("userinfo: \(message.token)")
70 | } catch let errror as NSError{
71 | print("Error handling mush message \(errror.localizedDescription)")
72 | }
73 |
74 | completionHandler(.newData)
75 | }
76 |
77 |
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample.xcodeproj/xcshareddata/xcschemes/ChatSecurePushExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
67 |
68 |
78 |
80 |
86 |
87 |
88 |
89 |
90 |
91 |
97 |
99 |
105 |
106 |
107 |
108 |
110 |
111 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExampleTests/URLMockSetup.swift:
--------------------------------------------------------------------------------
1 | //
2 | // URLMockSetup.swift
3 | // ChatSecurePushExample
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | // Copyright (c) 2015 David Chiles. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import URLMock
11 | import ChatSecure_Push_iOS
12 |
13 | let baseURl = URL(string: "http://push.chatsecure/api/1/")!
14 | let otherMessageURL = URL(string: "http://example.com/api/1/messages/")!
15 | let username = "test"
16 | let password = "password"
17 | let email = "email@email.com"
18 | let authToken = "f96197bfcf724523cb95626786d8c3baf8d16ada"
19 | let apnsToken = "c8631d1938f161cae7539b9692fd85ddd4fda5398c0ef5dc5e208b86612c322a"
20 | let dateCreatedSring = "2015-07-07T22:59:33.909289Z"
21 | let dateExpires = "2016-07-11T20:01:14.126Z"
22 | let deviceName = "Great big iPad"
23 | let tokenName = "This awesome token"
24 | let whitelistToken = "e6a73da924cfcf41d4a422e115e65d6f3e64fe3d"
25 | let errorToken = "errorToken"
26 |
27 | func setupURLMock() {
28 |
29 |
30 |
31 | var baseHeader = [
32 | "Accept-Encoding":"gzip;q=1.0,compress;q=0.5",
33 | "Accept":"application/json",
34 | ]
35 |
36 | var createAccountHeader = baseHeader
37 | createAccountHeader["Content-Type"] = "application/json"
38 |
39 | var postHeader = createAccountHeader
40 | postHeader["Authorization"] = "Token "+authToken
41 | baseHeader["Authorization"] = postHeader["Authorization"]
42 |
43 | let accountURL = baseURl.appendingPathComponent("accounts/")
44 |
45 |
46 | ///Create Account Request
47 | let createAccountRequest = UMKMockURLProtocol.expectMockHTTPPostRequest(with: accountURL, requestJSON: ["username":username,
48 | "password":password,
49 | "email":email],
50 | responseStatusCode: 200,
51 | responseJSON: [
52 | "username": username,
53 | "email": email,
54 | "token": authToken
55 | ])
56 | createAccountRequest.headers = createAccountHeader
57 | createAccountRequest.headers.updateValue("67", forKey: "Content-Length")
58 | //Need to figure out way to include "Content-Length" which is added by Apple
59 | createAccountRequest.checksHeadersWhenMatching = true
60 |
61 |
62 |
63 |
64 | ///Create Device Request
65 | let deviceURL = baseURl.appendingPathComponent("device/apns/")
66 | let deviceRequest = UMKMockURLProtocol.expectMockHTTPPostRequest(with: deviceURL, requestJSON: ["name":deviceName,
67 | "registration_id":apnsToken],
68 | responseStatusCode: 200,
69 | responseJSON: [
70 | "name": deviceName,
71 | "registration_id": apnsToken,
72 | "active": true,
73 | "date_created": dateCreatedSring
74 | ])
75 | deviceRequest.headers = postHeader
76 | deviceRequest.headers.updateValue("110", forKey: "Content-Length")
77 | deviceRequest.checksHeadersWhenMatching = true
78 |
79 |
80 | ///Create Token Request
81 | let tokenURL = baseURl.appendingPathComponent("tokens/")
82 |
83 | let tokenRequest = UMKMockURLProtocol.expectMockHTTPPostRequest(with: tokenURL, requestJSON: [
84 | "name":tokenName,
85 | "apns_device":apnsToken],
86 | responseStatusCode: 200,
87 | responseJSON: [
88 | "name": tokenName,
89 | "token": whitelistToken,
90 | "apns_device": apnsToken,
91 | "date_expires":dateExpires
92 | ])
93 |
94 | tokenRequest.headers = postHeader
95 | tokenRequest.headers.updateValue("110", forKey: "Content-Length")
96 | tokenRequest.checksHeadersWhenMatching = true
97 |
98 | let getSingleTokenRequest = UMKPatternMatchingMockRequest(urlPattern: tokenURL.absoluteString + ":id")
99 |
100 | getSingleTokenRequest.httpMethods = Set(["GET","DELETE"])
101 | getSingleTokenRequest.responderGenerationBlock = {request, parameters in
102 |
103 | if (request.httpMethod == "DELETE") {
104 | return UMKMockHTTPResponder(statusCode: 204, body: nil);
105 | }
106 |
107 | assert(request.value(forHTTPHeaderField: "Authorization") != nil)
108 |
109 | var data:Data?
110 | var json:[String:AnyObject]?
111 | if let id = parameters["id"] {
112 | var t = Token.randomToken()
113 | t = Token(tokenString: id, type:t.type, deviceID: t.registrationID)
114 | json = try! Serializer.jsonValue(t)
115 | } else {
116 | var results: [[String:AnyObject]] = []
117 | let count = 3
118 | for _ in 1...count {
119 | let t = Token.randomToken()
120 | if let json = try! Serializer.jsonValue(t) {
121 | results.append(json)
122 | }
123 | }
124 | json = ["count": count as AnyObject, "results": results as AnyObject]
125 |
126 | }
127 |
128 | if let j = json {
129 | do {
130 | data = try JSONSerialization.data(withJSONObject: j, options: JSONSerialization.WritingOptions())
131 | } catch {
132 | print("JSON Error")
133 | }
134 |
135 | }
136 |
137 | return UMKMockHTTPResponder(statusCode: 200, body: data);
138 | }
139 | let allTokenRequest = UMKPatternMatchingMockRequest(urlPattern: tokenURL.absoluteString)
140 | allTokenRequest.httpMethods = getSingleTokenRequest.httpMethods
141 | allTokenRequest.responderGenerationBlock = getSingleTokenRequest.responderGenerationBlock
142 |
143 |
144 | UMKMockURLProtocol.expectMockRequest(allTokenRequest)
145 | UMKMockURLProtocol.expectMockRequest(getSingleTokenRequest)
146 |
147 |
148 | /// Message Request
149 | let messageURL = baseURl.appendingPathComponent("messages/")
150 |
151 | let request = UMKPatternMatchingMockRequest(urlPattern: messageURL.absoluteString)
152 | let block:UMKParameterizedResponderGenerationBlock = {request, parameters in
153 |
154 | assert(request.value(forHTTPHeaderField: "Authorization") == nil)
155 |
156 | let data = (request as NSURLRequest).umk_HTTPBodyData()!
157 | let jsonDict = try! JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as! [String : AnyObject]
158 | let message = try! Deserializer.messageFromServerDictionary(jsonDict, url: request.url!)
159 |
160 | if (message.token == errorToken) {
161 | return UMKMockHTTPResponder(statusCode: 404)
162 | } else {
163 | //Return post data back to client
164 | return UMKMockHTTPResponder(statusCode: 200, body: (request as NSURLRequest).umk_HTTPBodyData());
165 | }
166 |
167 |
168 | }
169 | request.responderGenerationBlock = block
170 | UMKMockURLProtocol.expectMockRequest(request)
171 |
172 | let otherServerRequest = UMKPatternMatchingMockRequest(urlPattern: otherMessageURL.absoluteString)
173 | otherServerRequest.responderGenerationBlock = block
174 | UMKMockURLProtocol.expectMockRequest(otherServerRequest)
175 | }
176 |
177 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Deserializer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Serializer.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 | var dispatchToken: Int = 0
12 | var defaultDateFormatter = DateFormatter()
13 |
14 | open class Deserializer {
15 |
16 | private static var __once: () = { () -> Void in
17 | defaultDateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z"
18 | }()
19 |
20 | //Unsure if this is the most 'Swift' way to do this
21 | open class func dateFormatter() -> DateFormatter {
22 | _ = Deserializer.__once
23 | return defaultDateFormatter
24 | }
25 |
26 | open class func account(withData data: Data) throws -> Account {
27 |
28 | guard let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as? [String: String] else {
29 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"Unable to deserialize JSON as String:String"])
30 | }
31 |
32 | guard let username = json[jsonKeys.username.rawValue] else {
33 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing username"])
34 | }
35 | let account = Account(username: username)
36 | if let token = json[jsonKeys.token.rawValue] {
37 | account.token = token
38 | }
39 |
40 | if let email = json[jsonKeys.email.rawValue] {
41 | account.email = email
42 | }
43 | return account
44 | }
45 |
46 | open class func device(_ data: Data, kind: DeviceKind) throws -> Device {
47 |
48 | guard let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as? [String: AnyObject] else {
49 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"Unable to deserialize JSON as String:AnyObject"])
50 | }
51 |
52 | guard let registrationID = json[jsonKeys.registrationID.rawValue] as? String else {
53 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing registartion ID"])
54 | }
55 |
56 | guard let dateCreatedString = json[jsonKeys.dateCreated.rawValue] as? String else {
57 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing date created"])
58 | }
59 |
60 | guard let dateCreated = self.dateFormatter().date(from: dateCreatedString) else {
61 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON date wrong format"])
62 | }
63 |
64 | let deviceName = json[jsonKeys.name.rawValue] as? String
65 | let deviceID = json[jsonKeys.deviceID.rawValue] as? String
66 | let id = json[jsonKeys.id.rawValue] as? String
67 |
68 | return Device(registrationID: registrationID, dateCreated: dateCreated, name: deviceName, deviceID: deviceID, id: id)
69 | }
70 |
71 | open class func token(_ jsonDictionary:[String:AnyObject]) throws -> Token {
72 | guard let tokenString = jsonDictionary[jsonKeys.token.rawValue] as? String else {
73 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing token string"])
74 | }
75 |
76 | var dateExpires:Date? = nil
77 | if let dateExpiresString = jsonDictionary[jsonKeys.dateExpires.rawValue] as? String {
78 | dateExpires = self.dateFormatter().date(from: dateExpiresString)
79 | }
80 |
81 | if let registrationId = jsonDictionary[jsonKeys.apnsDeviceKey.rawValue] as? String {
82 | let token = Token(tokenString: tokenString, type: DeviceKind.iOS, deviceID: registrationId)
83 | token.name = jsonDictionary[jsonKeys.name.rawValue] as? String
84 | token.expires = dateExpires
85 | return token
86 | } else if let registrationId = jsonDictionary[jsonKeys.gcmDeviceKey.rawValue] as? String {
87 | let token = Token(tokenString: tokenString, type: DeviceKind.android, deviceID: registrationId)
88 | token.name = jsonDictionary[jsonKeys.name.rawValue] as? String
89 | token.expires = dateExpires
90 | return token
91 | }
92 | else {
93 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing registration ID"])
94 | }
95 | }
96 |
97 | open class func token(_ data: Data) throws -> Token {
98 |
99 | guard let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as? [String: AnyObject] else {
100 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"Unable to deserialize JSON as String:AnyObject"])
101 | }
102 |
103 | return try self.token(json)
104 | }
105 |
106 | open class func tokens(_ data: Data) throws -> [Token] {
107 |
108 | guard let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as? [String: AnyObject] else {
109 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"Unable to deserialize JSON as String:AnyObject"])
110 | }
111 |
112 | guard let resultsArray = json[jsonKeys.results.rawValue] as? [[String: AnyObject]] else {
113 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing results Dictionary"])
114 | }
115 | var tokenArray : [Token] = []
116 | for (_,dict) in resultsArray.enumerated() {
117 | let token = try self.token(dict)
118 | tokenArray.append(token)
119 | }
120 |
121 | return tokenArray
122 | }
123 |
124 | open class func messageFromPushDictionary(_ userInfo:[AnyHashable: Any]) throws -> Message {
125 | guard let aps = userInfo[jsonKeys.apsKey.rawValue] as? [String:AnyObject] else {
126 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"Unable to deserialize JSON as [String:AnyObject]"])
127 | }
128 |
129 | guard let alert = aps[jsonKeys.alertKey.rawValue] as? [String:AnyObject] else {
130 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing alert dictionary"])
131 | }
132 |
133 | guard let message = alert[jsonKeys.messageKey.rawValue] as? [String: AnyObject] else {
134 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing message dictionary"])
135 | }
136 |
137 | guard let tokenString = message[jsonKeys.token.rawValue] as? String else {
138 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing token string"])
139 | }
140 |
141 | let dataDictionary = message[jsonKeys.dataKey.rawValue] as? [String: AnyObject];
142 | return Message(token: tokenString, url:nil, data: dataDictionary)
143 | }
144 |
145 | open class func messageFromServerDictionary(_ userInfo:[String: AnyObject], url:URL) throws -> Message {
146 | guard let tokenString = userInfo[jsonKeys.token.rawValue] as? String else {
147 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing token string"])
148 | }
149 |
150 | let dataDictionary = userInfo[jsonKeys.dataKey.rawValue] as? [String: AnyObject];
151 | return Message(token: tokenString, url:url, data: dataDictionary)
152 | }
153 |
154 | open class func message(_ data: Data, url:URL) throws -> Message {
155 |
156 | guard let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as? [String: AnyObject] else {
157 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"Unable to deserialize JSON as String:AnyObject"])
158 | }
159 | return try self.messageFromServerDictionary(json, url: url)
160 | }
161 |
162 | public class func pubsub(data: Data) throws -> String {
163 | guard let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as? [String: AnyObject] else {
164 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"Unable to deserialize JSON as String:AnyObject"])
165 | }
166 |
167 | guard let pubsub = json[jsonKeys.jid.rawValue] as? String else {
168 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.badJSON.rawValue, userInfo: [NSLocalizedDescriptionKey:"JSON missing pubsub string"])
169 | }
170 | return pubsub
171 | }
172 | }
173 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExampleTests/ChatSecurePushExampleTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ChatSecurePushExampleTests.swift
3 | // ChatSecurePushExampleTests
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | // Copyright (c) 2015 David Chiles. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import XCTest
11 | import URLMock
12 | import ChatSecure_Push_iOS
13 |
14 | class ChatSecurePushExampleTests: XCTestCase {
15 |
16 | override func setUp() {
17 | super.setUp()
18 | UMKMockURLProtocol.reset()
19 | UMKMockURLProtocol.enable()
20 | setupURLMock()
21 | }
22 |
23 | override func tearDown() {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | super.tearDown()
26 | UMKMockURLProtocol.disable()
27 | }
28 |
29 | func defaultClient(_ authToken:String?) -> Client {
30 | let configuration = URLSessionConfiguration.default
31 | configuration.protocolClasses = [UMKMockURLProtocol.self]
32 |
33 | var account :Account? = nil
34 | if (authToken != nil) {
35 | account = Account(username:username)
36 | account?.token = authToken
37 | }
38 |
39 | let client = Client(baseUrl: baseURl, urlSessionConfiguration: configuration,account: account)
40 | return client
41 | }
42 |
43 | func testCreatingClient() {
44 | let client = self.defaultClient(nil)
45 | let hasLength = (client.baseUrl.absoluteString).count > 0
46 | XCTAssertTrue(hasLength, "No base url")
47 | }
48 |
49 | func testCreatingAccount() {
50 | let client = self.defaultClient(nil)
51 | let expectation = self.expectation(description: "Creating Account")
52 |
53 | client.registerNewUser(username, password: password, email: email) { (account, error) -> Void in
54 |
55 |
56 | let correctUsername = account?.username == username
57 | let correctEmail = account?.email == email
58 | let correctToken = account?.token == authToken
59 |
60 | XCTAssertNil(error, "Error creating account \(String(describing: error))")
61 | XCTAssertTrue(correctUsername, "Incorrect username \(String(describing: account?.username))")
62 | XCTAssertTrue(correctEmail, "Incorrect email \(String(describing: account?.email))")
63 | XCTAssertTrue(correctToken, "Incorrect token \(String(describing: account?.token))")
64 |
65 | expectation.fulfill()
66 | }
67 |
68 | self.waitForExpectations(timeout: 10, handler: { (error) -> Void in
69 | if( error != nil) {
70 | print("\(String(describing: error))")
71 | }
72 | })
73 | }
74 |
75 | func testCreatingDevice() {
76 | let client = self.defaultClient(authToken)
77 |
78 | let expectation = self.expectation(description: "Creating Device")
79 |
80 | client.registerDevice(apnsToken, name: deviceName, deviceID: nil) { (device, error) -> Void in
81 | let correctDeviceName = device?.name == deviceName
82 | let correctAPNSToken = device?.registrationID == apnsToken
83 |
84 | XCTAssertNil(error, "Error creating device \(String(describing: error))")
85 | XCTAssertTrue(correctDeviceName, "Incorrect device name \(String(describing: device?.name))")
86 | XCTAssertTrue(correctAPNSToken, "Incorrect apns token \(String(describing: device?.registrationID))")
87 |
88 | expectation.fulfill()
89 | }
90 |
91 | self.waitForExpectations(timeout: 10, handler: { (error) -> Void in
92 | if( error != nil) {
93 | print("\(String(describing: error))")
94 | }
95 | })
96 | }
97 |
98 | func testCreatingToken() {
99 | let client = self.defaultClient(authToken)
100 |
101 | let expectation = self.expectation(description: "Creating Token")
102 |
103 | client.createToken(apnsToken, name: tokenName) { (token, error) -> Void in
104 | let correctDeviceName = token?.name == tokenName
105 | let correctApnsToken = token?.registrationID == apnsToken
106 | let correctToken = token?.tokenString == whitelistToken
107 | let correctTokenExpiresDate = token?.expires == Deserializer.dateFormatter().date(from: dateExpires)
108 |
109 | XCTAssertNil(error, "Erro creating token: \(String(describing: error))")
110 | XCTAssertTrue(correctDeviceName, "Incorrect device name \(String(describing: token?.name))")
111 | XCTAssertTrue(correctApnsToken, "Incorrect APNS token \(String(describing: token?.registrationID))")
112 | XCTAssertTrue(correctToken, "Incorrect token \(String(describing: token?.tokenString))")
113 | XCTAssertTrue(correctTokenExpiresDate, "Incorect expiration date \(String(describing: token?.expires))")
114 |
115 | expectation.fulfill()
116 | }
117 |
118 | self.waitForExpectations(timeout: 10, handler: { (error) -> Void in
119 | if( error != nil) {
120 | print("\(String(describing: error))")
121 | }
122 | })
123 | }
124 |
125 | func testGettingTokens() {
126 | let client = self.defaultClient(authToken)
127 |
128 | let expectation = self.expectation(description: "Getting multiple tokens")
129 | client.tokens(nil, completion: { (tokens, error) -> Void in
130 | XCTAssertGreaterThan(tokens!.count, 0, "No tokens found")
131 | XCTAssertNil(error, "Error \(String(describing: error))")
132 | expectation.fulfill()
133 | })
134 |
135 | self.waitForExpectations(timeout: 20, handler: { (error) -> Void in
136 | if error != nil {
137 | print("\(String(describing: error))")
138 | }
139 | })
140 | }
141 |
142 | /// Test deleting tokens
143 | func testDeletingToken() {
144 | let client = self.defaultClient(authToken)
145 |
146 | let expectation = self.expectation(description: "Deleting token")
147 | client.revokeToken("tokenID") { (error) -> Void in
148 | XCTAssertNil(error)
149 | expectation.fulfill()
150 | }
151 |
152 | self.waitForExpectations(timeout: 30) { (err) -> Void in
153 |
154 | }
155 | }
156 |
157 | func testSendingMessage() {
158 | let client = self.defaultClient(authToken)
159 |
160 | let expectation = self.expectation(description: "Sending Message")
161 | let dict = [
162 | "key":["key":"value"],
163 | "Help":"Me"
164 | ] as [String : Any]
165 |
166 | let originalMessage = Message(token:"23", url:nil, data:dict)
167 |
168 | client.sendMessage(originalMessage) { (newMessage, error) -> Void in
169 |
170 | let equalToken = originalMessage.token == newMessage?.token
171 |
172 | XCTAssertNil(error, "Error sending message \(String(describing: error))")
173 | XCTAssertTrue(equalToken, "Token not equal")
174 |
175 | expectation.fulfill()
176 | }
177 |
178 | self.waitForExpectations(timeout: 30, handler: { (error) -> Void in
179 | if error != nil {
180 | print("Error: \(String(describing: error))")
181 | }
182 | })
183 | }
184 |
185 | /// Teset 404 message response. Token was revoked case
186 | func testErrorSendingMessage() {
187 | let client = self.defaultClient(authToken)
188 |
189 | let expectation = self.expectation(description: "Error Sending Message")
190 |
191 | let message = Message(token: errorToken, url: nil, data: nil)
192 |
193 | client.sendMessage(message) { (message, error) -> Void in
194 | XCTAssertNil(message)
195 | guard let err = error as NSError? else {
196 | XCTFail()
197 | expectation.fulfill()
198 | return
199 | }
200 | XCTAssertEqual(err.code, 404)
201 | expectation.fulfill()
202 | }
203 |
204 | self.waitForExpectations(timeout: 30) { (err) -> Void in
205 | if (err != nil) {
206 | print("\(String(describing: err))")
207 | }
208 | }
209 | }
210 |
211 | /// Test sending messages that have a url
212 | func testSendingMessageOtherServer() {
213 | let client = self.defaultClient(authToken)
214 |
215 | let expectation = self.expectation(description: "Sending Message to other server")
216 | let dict = [
217 | "key":["key":"value"],
218 | "Help":"Me"
219 | ] as [String : Any]
220 |
221 | let origMessage = Message(token: "111", url: otherMessageURL, data: dict)
222 | client.sendMessage(origMessage) { (message, error) -> Void in
223 |
224 | expectation.fulfill()
225 | }
226 |
227 | self.waitForExpectations(timeout: 30) { (error) -> Void in
228 | if error != nil {
229 | print("Error: \(String(describing: error))")
230 | }
231 | }
232 | }
233 |
234 | func testAPNSResponse() {
235 | let token = "09bd6d3cb017959eeec6cf031dbf7ad60f0a3bcd"
236 | let dict : [String: Any] = ["aps": [
237 | "alert": [
238 | "message": [
239 | "token": token
240 | ]
241 | ],
242 | "content-available": 1
243 | ]]
244 | do {
245 | let message = try Deserializer.messageFromPushDictionary(dict)
246 | let equalToken = message.token == token
247 | XCTAssertTrue(equalToken, "Not equal token")
248 | } catch let error {
249 | XCTAssertNil(error)
250 | }
251 | }
252 | }
253 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
44 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
111 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
--------------------------------------------------------------------------------
/ChatSecurePush-SDK/Client.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Client.swift
3 | // Pods
4 | //
5 | // Created by David Chiles on 7/7/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 | public enum Method: String {
12 | case options = "OPTIONS"
13 | case get = "GET"
14 | case head = "HEAD"
15 | case post = "POST"
16 | case put = "PUT"
17 | case patch = "PATCH"
18 | case delete = "DELETE"
19 | }
20 |
21 | public enum Endpoint: String {
22 | case accounts = "accounts"
23 | case apns = "device/apns"
24 | case gcm = "device/gcm"
25 | case tokens = "tokens"
26 | case messages = "messages"
27 | case pubsub = "pubsub"
28 | }
29 |
30 | public enum jsonKeys: String {
31 | case username = "username"
32 | case password = "password"
33 | case email = "email"
34 | case token = "token"
35 | case registrationID = "registration_id"
36 | case name = "name"
37 | case deviceID = "device_id"
38 | case active = "active"
39 | case dateCreated = "date_created" //ISO-8601
40 | case dateExpires = "date_expires"
41 | case apnsDeviceKey = "apns_device"
42 | case gcmDeviceKey = "gcm_device"
43 | case dataKey = "data"
44 | case messageKey = "message"
45 | case apsKey = "aps"
46 | case alertKey = "alert"
47 | case id = "id"
48 | case results = "results"
49 | case jid = "jid"
50 | }
51 |
52 | /**
53 | An API client that performs calls to the [ChatSecure-Push-Server](https://github.com/chatsecure/chatsecure-push-server)
54 |
55 | Errors
56 | - The methods that involve network operations will return the HTTP status code in the range 100...500
57 | - Internal errors or non network errors will be in the 600 and greater range and are documented in Error.swift
58 | */
59 | @objc open class Client: NSObject {
60 | /// The API URL in the format in the format `https://example.com/api/v1/`
61 | @objc public let baseUrl: URL
62 | /// The url session to be used for calls to the server
63 | @objc public let urlSession: URLSession
64 | /// This is the queue where callbacks from the `Client` are executed on
65 | @objc open var callbackQueue = OperationQueue()
66 | /// The account containing the data need for server authentication. This needs to be set after `registerNewUser` with the returned account.
67 | @objc open var account: Account?
68 |
69 | fileprivate var appleDeviceEndpoint: APNSDeviceEndpoint
70 | fileprivate var accountEndpoint: AccountEnpoint
71 | fileprivate var tokenEndpoint: TokenEndpoint
72 | fileprivate var messageEndpoint: MessageEndpoint
73 | fileprivate var pubsubEndpoint: APIEndpoint
74 | fileprivate let urlSessionDelegate = URLSessionDelegate()
75 |
76 |
77 | /**
78 | Initializes an API Client with the URL to use in future methods.
79 |
80 | - Parameters:
81 | - baseUrl: The URL for the API server in the format `https://example.com/api/v1/`
82 | - urlSessionConfiguration: A valid session configuration default is `NSURLSessionConfiguration.defaultSessionConfiguration()`
83 | - account: If there is an already existsing account (possibly persisted to disk) it should be passed in here. It should have a valid token that is to be used to authenticate against the server
84 |
85 | - Returns: A new `Client`
86 | */
87 | @objc public init(baseUrl: URL, urlSessionConfiguration: URLSessionConfiguration = URLSessionConfiguration.default,account: Account?) {
88 | self.baseUrl = baseUrl
89 | self.urlSession = URLSession(configuration: urlSessionConfiguration, delegate: urlSessionDelegate, delegateQueue: nil)
90 | self.account = account
91 | self.appleDeviceEndpoint = APNSDeviceEndpoint(baseUrl: self.baseUrl)
92 | self.accountEndpoint = AccountEnpoint(baseUrl: self.baseUrl)
93 | self.tokenEndpoint = TokenEndpoint(baseUrl: self.baseUrl)
94 | self.messageEndpoint = MessageEndpoint(baseUrl: self.baseUrl)
95 | self.pubsubEndpoint = APIEndpoint(baseUrl: self.baseUrl)
96 | }
97 |
98 | // MARK: User
99 |
100 | /**
101 | Creates a new user on the remote server.
102 |
103 | - Parameters:
104 | - username: The desiered username for the new account
105 | - password: The desiered password for the new account
106 | - email: Optional email address. Useful for future password resets
107 | - completion: called once an account is created or an error occurs.
108 | */
109 | @objc open func registerNewUser(_ username: String, password: String, email: String?, completion: @escaping (_ account: Account?,_ error: NSError?) -> Void) {
110 | do {
111 | let request = try self.accountEndpoint.postRequest(username , password: password, email: email)
112 | self.startDataTask(request, completionHandler: { (data, response, error) -> Void in
113 | var account:Account? = nil
114 | var error:NSError? = nil
115 | do {
116 | account = try self.accountEndpoint.accountFromResponse(data, response: response, error: error)
117 | } catch let err as NSError {
118 | error = err
119 | }
120 |
121 | self.callbackQueue.addOperation({ () -> Void in
122 | completion(account,error)
123 | })
124 | })
125 | } catch let err as NSError {
126 | self.callbackQueue.addOperation({ () -> Void in
127 | completion(nil, err)
128 | })
129 | }
130 |
131 | }
132 |
133 | /** Careful, this will delete ALL data on the server. Must be logged in first. */
134 | @objc open func unregister(_ completion: @escaping (_ success: Bool, _ error: NSError?) -> Void) {
135 | guard let accountToDelete = account else {
136 | self.callbackQueue.addOperation({ () -> Void in
137 | completion(false, NSError.error(.creatingRequest, userInfo: [:]))
138 | })
139 | return
140 | }
141 | do {
142 | let request = try self.accountEndpoint.deleteRequest(accountToDelete)
143 | self.startDataTask(request, completionHandler: { (data, response, error) in
144 | var result = true
145 | var outError:NSError? = nil
146 | do {
147 | try self.accountEndpoint.handleError(data, response: response, error: error)
148 | } catch let err as NSError {
149 | outError = err
150 | result = false
151 | }
152 | self.callbackQueue.addOperation({ () -> Void in
153 | completion(result, outError)
154 | })
155 | })
156 | } catch let err as NSError {
157 | self.callbackQueue.addOperation({ () -> Void in
158 | completion(false, err)
159 | })
160 | }
161 | }
162 |
163 |
164 | // MARK: Device
165 |
166 | /**
167 | Register a new device.
168 |
169 | - Parameters:
170 | - APNSToken: This is the token received from Apple for 'this' device
171 | - name: Optional name for the device to make managing devices easier for the user
172 | - deviceID: Optional id to identify the device by
173 | - compltion: The completion closure called once a device is returned or there is an error
174 | */
175 | @objc open func registerDevice(_ APNSToken: String, name: String?, deviceID: String?, completion: @escaping (_ device: Device?, _ error: Error?) -> Void) {
176 | do {
177 | let request = try self.appleDeviceEndpoint.postRequest(APNSToken, name: name, deviceID: deviceID, serverID: nil)
178 | self.startDataTask(request, completionHandler: { (responseData, response, responseError) -> Void in
179 | var device:Device? = nil
180 | var error:NSError? = nil
181 | do {
182 | device = try self.appleDeviceEndpoint.deviceFromResponse(responseData, response: response, error: responseError)
183 | } catch let err as NSError {
184 | error = err
185 | }
186 |
187 |
188 | self.callbackQueue.addOperation({ () -> Void in
189 | completion(device, error)
190 | })
191 | })
192 | } catch let err as NSError {
193 | self.callbackQueue.addOperation({ () -> Void in
194 | completion(nil, err)
195 | })
196 | }
197 |
198 | }
199 | /**
200 | Update an existing device. Only updates fields that are present.
201 |
202 | - Parameters:
203 | - serverID: The id from the server to identify the device
204 | - APNSToken: The new or existing APNS token is required
205 | - name: Optional new name for the device
206 | - deviceID: Optional other id to call the device
207 | - completion: Called once the update is complete or there is an error
208 | */
209 | @objc open func updateDevice(_ serverID: String, APNSToken: String, name: String?, deviceID: String?, completion: @escaping (_ device: Device?, _ error: Error?) -> Void) {
210 |
211 | do {
212 | let request = try self.appleDeviceEndpoint.putRequest(APNSToken, name: name, deviceID: deviceID, serverID: serverID)
213 | self.startDataTask(request, completionHandler: { (responseData, response, responseError) -> Void in
214 | var device:Device? = nil
215 | var error:NSError? = nil
216 | do {
217 | device = try self.appleDeviceEndpoint.deviceFromResponse(responseData, response: response, error: responseError)
218 | } catch let err as NSError {
219 | error = err
220 | }
221 |
222 |
223 | self.callbackQueue.addOperation({ () -> Void in
224 | completion(device, error)
225 | })
226 | })
227 | } catch let err as NSError {
228 | self.callbackQueue.addOperation({ () -> Void in
229 | completion(nil, err)
230 | })
231 | }
232 |
233 | }
234 |
235 | // MARK: Token
236 |
237 | /**
238 | Creates a new 'whitelist' token to give to others you want to allow to send push notifications to this account
239 |
240 | - Parameters:
241 | - id: The id of this APNS device
242 | - name: Optional name of the token for managing tokens later
243 | - completion: Called once there is a valid token or there is an error
244 | */
245 | @objc open func createToken(_ id:String ,name:String?, completion: @escaping (_ token: Token?, _ error: Error?) -> Void ) {
246 | do {
247 | let request = try self.tokenEndpoint.postRequest(id , name: name)
248 | self.startDataTask(request, completionHandler: { (responseData, response, responseError) -> Void in
249 | var token:Token? = nil
250 | var error:NSError? = nil
251 | do {
252 | token = try self.tokenEndpoint.tokenFromResponse(responseData , response: response, error: responseError)
253 | } catch let err as NSError {
254 | error = err
255 | }
256 |
257 | self.callbackQueue.addOperation({ () -> Void in
258 | completion(token, error)
259 | })
260 | })
261 | } catch let err as NSError {
262 | self.callbackQueue.addOperation({ () -> Void in
263 | completion(nil, err)
264 | })
265 | }
266 |
267 | }
268 |
269 | /**
270 | Fetches token(s) from the server. If an id is passed then the resulting array will contain at most one token
271 |
272 | - Parameters:
273 | - id: Optional id. Pass if you want only a specific token. If none is passed it fetches all tokens
274 | - completion: The tokens from the server or an error
275 | */
276 | @objc open func tokens(_ id:String?, completion:@escaping (_ tokens: [Token]?, _ error: Error?) -> Void) {
277 | do {
278 | let request = try self.tokenEndpoint.getRequest(id)
279 | self.startDataTask(request, completionHandler: { (responseData, response, responseError) -> Void in
280 | var tokens:[Token]? = nil
281 | var error:NSError? = nil
282 | do {
283 | tokens = try self.tokenEndpoint.tokensFromResponse(responseData , response: response, error: responseError)
284 | } catch let err as NSError {
285 | error = err
286 | }
287 |
288 | self.callbackQueue.addOperation({ () -> Void in
289 | completion(tokens, error)
290 | })
291 | })
292 | } catch let err as NSError {
293 | self.callbackQueue.addOperation({ () -> Void in
294 | completion(nil, err)
295 | })
296 | }
297 |
298 | }
299 |
300 | /**
301 | Delete a token from the remote server. This makes it impossible for this token to send push messages.
302 |
303 | - Parameters:
304 | - id: The token string, e.g. 852e1c575a8f86b9198d4c13ecccac3634873859
305 | - completion: The closure called on completion and any error if encountered.
306 | */
307 | @objc open func revokeToken(_ id:String, completion:@escaping (_ error: Error?) -> Void) {
308 | do {
309 | let reqeust = try self.tokenEndpoint.deleteRequest(id)
310 | self.startDataTask(reqeust, completionHandler: { [weak self] (data, response, error) -> Void in
311 | self?.callbackQueue.addOperation({ () -> Void in
312 | completion(error)
313 | })
314 | })
315 | } catch let error as NSError {
316 | self.callbackQueue.addOperation({ () -> Void in
317 | completion(error)
318 | })
319 | }
320 | }
321 |
322 | // MARK: Message
323 | /// The url for the message endpoint for this client
324 | @objc open func messageEndpont() -> URL {
325 | return self.baseUrl.appendingPathComponent("\(Endpoint.messages.rawValue)/")
326 | }
327 | /**
328 | Sends a message object to initiate a push. If the message does not have a url then it will be sent to this client's message endpoint otherwise that url is used.
329 |
330 | - Parameters:
331 | - message: The message object to be sent
332 | - completion: Called once the message object is returned from teh the server or an error
333 | */
334 | @objc open func sendMessage(_ message:Message, completion: @escaping (_ message: Message?, _ error: Error?) -> Void ) {
335 | do {
336 | let request = try self.messageEndpoint.postRequest(message)
337 |
338 | self.startDataTask(request,authenticate: false, completionHandler: { (responseData, response, responseError) -> Void in
339 | var message:Message? = nil
340 | var error:NSError? = nil
341 | do {
342 | message = try self.messageEndpoint.messageFromResponse(responseData , response: response, error: responseError)
343 | } catch let err as NSError {
344 | error = err
345 | }
346 |
347 | self.callbackQueue.addOperation({ () -> Void in
348 | completion(message, error)
349 | })
350 | })
351 | } catch let error as NSError {
352 | self.callbackQueue.addOperation({ () -> Void in
353 | completion(nil, error)
354 | })
355 | }
356 | }
357 |
358 | // MARK: Pubsub (XEP-0357)
359 | @objc open func getPubsubEndpoint(_ completion: @escaping (_ pubsubEndpoint:String?,_ error:Error?) -> Void) {
360 | do {
361 | let request = try self.pubsubEndpoint.request(.get, endpoint: Endpoint.pubsub.rawValue, jsonDictionary: nil)
362 |
363 | self.startDataTask(request,authenticate: false, completionHandler: { (responseData, response, responseError) -> Void in
364 | var endpoint:String? = nil
365 | var error:NSError? = nil
366 | do {
367 | try self.pubsubEndpoint.handleError(responseData, response: response, error: error)
368 |
369 | guard let data = responseData else {
370 | throw NSError(domain: ErrorDomain.chatsecurePush.rawValue, code: ErrorStatusCode.noData.rawValue, userInfo: nil)
371 | }
372 |
373 | endpoint = try Deserializer.pubsub(data: data)
374 | } catch let err as NSError {
375 | error = err
376 | }
377 |
378 | self.callbackQueue.addOperation({ () -> Void in
379 | completion(endpoint, error)
380 | })
381 | })
382 |
383 | } catch let error as NSError {
384 | self.callbackQueue.addOperation({ () -> Void in
385 | completion(nil, error)
386 | })
387 | }
388 | }
389 |
390 |
391 | // MARK: Data Task
392 | /**
393 | Default way of starting a data task for all network calls.
394 |
395 | - Parameters:
396 | - request: the mutable url request to use. This request will have it's headers modififed to us 'Accept-Encoding' and 'Accept'
397 | - authenticate: default true. Whether to include the account authentication token
398 | - completionHandler: Called with result from server
399 | */
400 | func startDataTask(_ request: URLRequest, authenticate:Bool = true, completionHandler: @escaping ((Data?, URLResponse?, Error?) -> Void))
401 | {
402 | var requestWithAuth = request
403 | requestWithAuth.setValue("gzip;q=1.0,compress;q=0.5", forHTTPHeaderField: "Accept-Encoding")
404 | requestWithAuth.setValue("application/json", forHTTPHeaderField:"Accept")
405 | if let token = self.account?.token, authenticate {
406 | requestWithAuth.setValue("Token "+token, forHTTPHeaderField:"Authorization")
407 | }
408 |
409 | let dataTask = self.urlSession.dataTask(with: requestWithAuth, completionHandler: completionHandler)
410 | dataTask.resume()
411 | }
412 | }
413 |
--------------------------------------------------------------------------------
/ChatSecurePushExample/ChatSecurePushExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1D4733280727E079624C37B8 /* Pods_ChatSecurePushExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A65AB8FFC01D302231BE3B43 /* Pods_ChatSecurePushExample.framework */; };
11 | 637BAEBA1B5ED006007CC92A /* AccountDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637BAEB91B5ED005007CC92A /* AccountDetailViewController.swift */; };
12 | 638C25301B4C43D600AB62CB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638C252F1B4C43D600AB62CB /* AppDelegate.swift */; };
13 | 638C25321B4C43D600AB62CB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638C25311B4C43D600AB62CB /* ViewController.swift */; };
14 | 638C25351B4C43D600AB62CB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 638C25331B4C43D600AB62CB /* Main.storyboard */; };
15 | 638C25371B4C43D600AB62CB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 638C25361B4C43D600AB62CB /* Images.xcassets */; };
16 | 638C253A1B4C43D600AB62CB /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 638C25381B4C43D600AB62CB /* LaunchScreen.xib */; };
17 | 638C25461B4C43D600AB62CB /* ChatSecurePushExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638C25451B4C43D600AB62CB /* ChatSecurePushExampleTests.swift */; };
18 | 638C255C1B4C7BB300AB62CB /* URLMockSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638C255B1B4C7BB300AB62CB /* URLMockSetup.swift */; };
19 | 63F6DBE11B97AF6E0079E295 /* TestObjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F6DBE01B97AF6E0079E295 /* TestObjects.swift */; };
20 | E3AC63CFEE60D4886E082B2D /* Pods_ChatSecurePushExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CC6F167DC8136D21C3A7EE9 /* Pods_ChatSecurePushExampleTests.framework */; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXContainerItemProxy section */
24 | 638C25401B4C43D600AB62CB /* PBXContainerItemProxy */ = {
25 | isa = PBXContainerItemProxy;
26 | containerPortal = 638C25221B4C43D600AB62CB /* Project object */;
27 | proxyType = 1;
28 | remoteGlobalIDString = 638C25291B4C43D600AB62CB;
29 | remoteInfo = ChatSecurePushExample;
30 | };
31 | /* End PBXContainerItemProxy section */
32 |
33 | /* Begin PBXFileReference section */
34 | 1E518B8D8689CA093E280953 /* Pods-ChatSecurePushExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChatSecurePushExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ChatSecurePushExample/Pods-ChatSecurePushExample.debug.xcconfig"; sourceTree = ""; };
35 | 637BAEB91B5ED005007CC92A /* AccountDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountDetailViewController.swift; sourceTree = ""; };
36 | 638C252A1B4C43D600AB62CB /* ChatSecurePushExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChatSecurePushExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
37 | 638C252E1B4C43D600AB62CB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
38 | 638C252F1B4C43D600AB62CB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
39 | 638C25311B4C43D600AB62CB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
40 | 638C25341B4C43D600AB62CB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
41 | 638C25361B4C43D600AB62CB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
42 | 638C25391B4C43D600AB62CB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
43 | 638C253F1B4C43D600AB62CB /* ChatSecurePushExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChatSecurePushExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
44 | 638C25441B4C43D600AB62CB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
45 | 638C25451B4C43D600AB62CB /* ChatSecurePushExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatSecurePushExampleTests.swift; sourceTree = ""; };
46 | 638C255A1B4C771000AB62CB /* ChatSecurePushExampleTests-header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ChatSecurePushExampleTests-header.h"; sourceTree = ""; };
47 | 638C255B1B4C7BB300AB62CB /* URLMockSetup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLMockSetup.swift; sourceTree = ""; };
48 | 63F6DBE01B97AF6E0079E295 /* TestObjects.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestObjects.swift; sourceTree = ""; };
49 | 985A1CBBB5BE48DD94C689F6 /* Pods-ChatSecurePushExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChatSecurePushExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-ChatSecurePushExample/Pods-ChatSecurePushExample.release.xcconfig"; sourceTree = ""; };
50 | 9CC6F167DC8136D21C3A7EE9 /* Pods_ChatSecurePushExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ChatSecurePushExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
51 | A65AB8FFC01D302231BE3B43 /* Pods_ChatSecurePushExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ChatSecurePushExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
52 | E2D649C3FAACCE12A4DC1C88 /* Pods-ChatSecurePushExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChatSecurePushExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ChatSecurePushExampleTests/Pods-ChatSecurePushExampleTests.release.xcconfig"; sourceTree = ""; };
53 | E45F6CD065C806750B98234F /* Pods-ChatSecurePushExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChatSecurePushExampleTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ChatSecurePushExampleTests/Pods-ChatSecurePushExampleTests.debug.xcconfig"; sourceTree = ""; };
54 | /* End PBXFileReference section */
55 |
56 | /* Begin PBXFrameworksBuildPhase section */
57 | 638C25271B4C43D600AB62CB /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | 1D4733280727E079624C37B8 /* Pods_ChatSecurePushExample.framework in Frameworks */,
62 | );
63 | runOnlyForDeploymentPostprocessing = 0;
64 | };
65 | 638C253C1B4C43D600AB62CB /* Frameworks */ = {
66 | isa = PBXFrameworksBuildPhase;
67 | buildActionMask = 2147483647;
68 | files = (
69 | E3AC63CFEE60D4886E082B2D /* Pods_ChatSecurePushExampleTests.framework in Frameworks */,
70 | );
71 | runOnlyForDeploymentPostprocessing = 0;
72 | };
73 | /* End PBXFrameworksBuildPhase section */
74 |
75 | /* Begin PBXGroup section */
76 | 4360F2354362F7043C5F22D5 /* Pods */ = {
77 | isa = PBXGroup;
78 | children = (
79 | 1E518B8D8689CA093E280953 /* Pods-ChatSecurePushExample.debug.xcconfig */,
80 | 985A1CBBB5BE48DD94C689F6 /* Pods-ChatSecurePushExample.release.xcconfig */,
81 | E45F6CD065C806750B98234F /* Pods-ChatSecurePushExampleTests.debug.xcconfig */,
82 | E2D649C3FAACCE12A4DC1C88 /* Pods-ChatSecurePushExampleTests.release.xcconfig */,
83 | );
84 | name = Pods;
85 | sourceTree = "";
86 | };
87 | 638C25211B4C43D600AB62CB = {
88 | isa = PBXGroup;
89 | children = (
90 | 638C252C1B4C43D600AB62CB /* ChatSecurePushExample */,
91 | 638C25421B4C43D600AB62CB /* ChatSecurePushExampleTests */,
92 | 638C252B1B4C43D600AB62CB /* Products */,
93 | 4360F2354362F7043C5F22D5 /* Pods */,
94 | E875A4BF17D91C35DE8A44A1 /* Frameworks */,
95 | );
96 | sourceTree = "";
97 | };
98 | 638C252B1B4C43D600AB62CB /* Products */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 638C252A1B4C43D600AB62CB /* ChatSecurePushExample.app */,
102 | 638C253F1B4C43D600AB62CB /* ChatSecurePushExampleTests.xctest */,
103 | );
104 | name = Products;
105 | sourceTree = "";
106 | };
107 | 638C252C1B4C43D600AB62CB /* ChatSecurePushExample */ = {
108 | isa = PBXGroup;
109 | children = (
110 | 638C252F1B4C43D600AB62CB /* AppDelegate.swift */,
111 | 638C25311B4C43D600AB62CB /* ViewController.swift */,
112 | 637BAEB91B5ED005007CC92A /* AccountDetailViewController.swift */,
113 | 638C25331B4C43D600AB62CB /* Main.storyboard */,
114 | 638C25361B4C43D600AB62CB /* Images.xcassets */,
115 | 638C25381B4C43D600AB62CB /* LaunchScreen.xib */,
116 | 638C252D1B4C43D600AB62CB /* Supporting Files */,
117 | );
118 | path = ChatSecurePushExample;
119 | sourceTree = "";
120 | };
121 | 638C252D1B4C43D600AB62CB /* Supporting Files */ = {
122 | isa = PBXGroup;
123 | children = (
124 | 638C252E1B4C43D600AB62CB /* Info.plist */,
125 | );
126 | name = "Supporting Files";
127 | sourceTree = "";
128 | };
129 | 638C25421B4C43D600AB62CB /* ChatSecurePushExampleTests */ = {
130 | isa = PBXGroup;
131 | children = (
132 | 638C25451B4C43D600AB62CB /* ChatSecurePushExampleTests.swift */,
133 | 638C255B1B4C7BB300AB62CB /* URLMockSetup.swift */,
134 | 63F6DBE01B97AF6E0079E295 /* TestObjects.swift */,
135 | 638C25431B4C43D600AB62CB /* Supporting Files */,
136 | 638C255A1B4C771000AB62CB /* ChatSecurePushExampleTests-header.h */,
137 | );
138 | path = ChatSecurePushExampleTests;
139 | sourceTree = "";
140 | };
141 | 638C25431B4C43D600AB62CB /* Supporting Files */ = {
142 | isa = PBXGroup;
143 | children = (
144 | 638C25441B4C43D600AB62CB /* Info.plist */,
145 | );
146 | name = "Supporting Files";
147 | sourceTree = "";
148 | };
149 | E875A4BF17D91C35DE8A44A1 /* Frameworks */ = {
150 | isa = PBXGroup;
151 | children = (
152 | A65AB8FFC01D302231BE3B43 /* Pods_ChatSecurePushExample.framework */,
153 | 9CC6F167DC8136D21C3A7EE9 /* Pods_ChatSecurePushExampleTests.framework */,
154 | );
155 | name = Frameworks;
156 | sourceTree = "";
157 | };
158 | /* End PBXGroup section */
159 |
160 | /* Begin PBXNativeTarget section */
161 | 638C25291B4C43D600AB62CB /* ChatSecurePushExample */ = {
162 | isa = PBXNativeTarget;
163 | buildConfigurationList = 638C25491B4C43D600AB62CB /* Build configuration list for PBXNativeTarget "ChatSecurePushExample" */;
164 | buildPhases = (
165 | 902BB9ABD51F1528F455D798 /* [CP] Check Pods Manifest.lock */,
166 | 638C25261B4C43D600AB62CB /* Sources */,
167 | 638C25271B4C43D600AB62CB /* Frameworks */,
168 | 638C25281B4C43D600AB62CB /* Resources */,
169 | D0C0AF764E8720E1D8CFB06F /* [CP] Embed Pods Frameworks */,
170 | );
171 | buildRules = (
172 | );
173 | dependencies = (
174 | );
175 | name = ChatSecurePushExample;
176 | productName = ChatSecurePushExample;
177 | productReference = 638C252A1B4C43D600AB62CB /* ChatSecurePushExample.app */;
178 | productType = "com.apple.product-type.application";
179 | };
180 | 638C253E1B4C43D600AB62CB /* ChatSecurePushExampleTests */ = {
181 | isa = PBXNativeTarget;
182 | buildConfigurationList = 638C254C1B4C43D600AB62CB /* Build configuration list for PBXNativeTarget "ChatSecurePushExampleTests" */;
183 | buildPhases = (
184 | 07E94FAF11E9853F4A3F4553 /* [CP] Check Pods Manifest.lock */,
185 | 638C253B1B4C43D600AB62CB /* Sources */,
186 | 638C253C1B4C43D600AB62CB /* Frameworks */,
187 | 638C253D1B4C43D600AB62CB /* Resources */,
188 | 550F298DF95A134E14C6F6DE /* [CP] Embed Pods Frameworks */,
189 | );
190 | buildRules = (
191 | );
192 | dependencies = (
193 | 638C25411B4C43D600AB62CB /* PBXTargetDependency */,
194 | );
195 | name = ChatSecurePushExampleTests;
196 | productName = ChatSecurePushExampleTests;
197 | productReference = 638C253F1B4C43D600AB62CB /* ChatSecurePushExampleTests.xctest */;
198 | productType = "com.apple.product-type.bundle.unit-test";
199 | };
200 | /* End PBXNativeTarget section */
201 |
202 | /* Begin PBXProject section */
203 | 638C25221B4C43D600AB62CB /* Project object */ = {
204 | isa = PBXProject;
205 | attributes = {
206 | LastSwiftMigration = 0700;
207 | LastSwiftUpdateCheck = 0700;
208 | LastUpgradeCheck = 1010;
209 | ORGANIZATIONNAME = "David Chiles";
210 | TargetAttributes = {
211 | 638C25291B4C43D600AB62CB = {
212 | CreatedOnToolsVersion = 6.4;
213 | LastSwiftMigration = 1020;
214 | SystemCapabilities = {
215 | com.apple.BackgroundModes = {
216 | enabled = 1;
217 | };
218 | };
219 | };
220 | 638C253E1B4C43D600AB62CB = {
221 | CreatedOnToolsVersion = 6.4;
222 | LastSwiftMigration = 1020;
223 | TestTargetID = 638C25291B4C43D600AB62CB;
224 | };
225 | };
226 | };
227 | buildConfigurationList = 638C25251B4C43D600AB62CB /* Build configuration list for PBXProject "ChatSecurePushExample" */;
228 | compatibilityVersion = "Xcode 3.2";
229 | developmentRegion = en;
230 | hasScannedForEncodings = 0;
231 | knownRegions = (
232 | en,
233 | Base,
234 | );
235 | mainGroup = 638C25211B4C43D600AB62CB;
236 | productRefGroup = 638C252B1B4C43D600AB62CB /* Products */;
237 | projectDirPath = "";
238 | projectRoot = "";
239 | targets = (
240 | 638C25291B4C43D600AB62CB /* ChatSecurePushExample */,
241 | 638C253E1B4C43D600AB62CB /* ChatSecurePushExampleTests */,
242 | );
243 | };
244 | /* End PBXProject section */
245 |
246 | /* Begin PBXResourcesBuildPhase section */
247 | 638C25281B4C43D600AB62CB /* Resources */ = {
248 | isa = PBXResourcesBuildPhase;
249 | buildActionMask = 2147483647;
250 | files = (
251 | 638C25351B4C43D600AB62CB /* Main.storyboard in Resources */,
252 | 638C253A1B4C43D600AB62CB /* LaunchScreen.xib in Resources */,
253 | 638C25371B4C43D600AB62CB /* Images.xcassets in Resources */,
254 | );
255 | runOnlyForDeploymentPostprocessing = 0;
256 | };
257 | 638C253D1B4C43D600AB62CB /* Resources */ = {
258 | isa = PBXResourcesBuildPhase;
259 | buildActionMask = 2147483647;
260 | files = (
261 | );
262 | runOnlyForDeploymentPostprocessing = 0;
263 | };
264 | /* End PBXResourcesBuildPhase section */
265 |
266 | /* Begin PBXShellScriptBuildPhase section */
267 | 07E94FAF11E9853F4A3F4553 /* [CP] Check Pods Manifest.lock */ = {
268 | isa = PBXShellScriptBuildPhase;
269 | buildActionMask = 2147483647;
270 | files = (
271 | );
272 | inputPaths = (
273 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
274 | "${PODS_ROOT}/Manifest.lock",
275 | );
276 | name = "[CP] Check Pods Manifest.lock";
277 | outputPaths = (
278 | "$(DERIVED_FILE_DIR)/Pods-ChatSecurePushExampleTests-checkManifestLockResult.txt",
279 | );
280 | runOnlyForDeploymentPostprocessing = 0;
281 | shellPath = /bin/sh;
282 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
283 | showEnvVarsInLog = 0;
284 | };
285 | 550F298DF95A134E14C6F6DE /* [CP] Embed Pods Frameworks */ = {
286 | isa = PBXShellScriptBuildPhase;
287 | buildActionMask = 2147483647;
288 | files = (
289 | );
290 | inputPaths = (
291 | "${PODS_ROOT}/Target Support Files/Pods-ChatSecurePushExampleTests/Pods-ChatSecurePushExampleTests-frameworks.sh",
292 | "${BUILT_PRODUCTS_DIR}/ChatSecure-Push-iOS/ChatSecure_Push_iOS.framework",
293 | "${BUILT_PRODUCTS_DIR}/SOCKit/SOCKit.framework",
294 | "${BUILT_PRODUCTS_DIR}/URLMock/URLMock.framework",
295 | );
296 | name = "[CP] Embed Pods Frameworks";
297 | outputPaths = (
298 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ChatSecure_Push_iOS.framework",
299 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SOCKit.framework",
300 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/URLMock.framework",
301 | );
302 | runOnlyForDeploymentPostprocessing = 0;
303 | shellPath = /bin/sh;
304 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ChatSecurePushExampleTests/Pods-ChatSecurePushExampleTests-frameworks.sh\"\n";
305 | showEnvVarsInLog = 0;
306 | };
307 | 902BB9ABD51F1528F455D798 /* [CP] Check Pods Manifest.lock */ = {
308 | isa = PBXShellScriptBuildPhase;
309 | buildActionMask = 2147483647;
310 | files = (
311 | );
312 | inputPaths = (
313 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
314 | "${PODS_ROOT}/Manifest.lock",
315 | );
316 | name = "[CP] Check Pods Manifest.lock";
317 | outputPaths = (
318 | "$(DERIVED_FILE_DIR)/Pods-ChatSecurePushExample-checkManifestLockResult.txt",
319 | );
320 | runOnlyForDeploymentPostprocessing = 0;
321 | shellPath = /bin/sh;
322 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
323 | showEnvVarsInLog = 0;
324 | };
325 | D0C0AF764E8720E1D8CFB06F /* [CP] Embed Pods Frameworks */ = {
326 | isa = PBXShellScriptBuildPhase;
327 | buildActionMask = 2147483647;
328 | files = (
329 | );
330 | inputPaths = (
331 | "${PODS_ROOT}/Target Support Files/Pods-ChatSecurePushExample/Pods-ChatSecurePushExample-frameworks.sh",
332 | "${BUILT_PRODUCTS_DIR}/ChatSecure-Push-iOS/ChatSecure_Push_iOS.framework",
333 | );
334 | name = "[CP] Embed Pods Frameworks";
335 | outputPaths = (
336 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ChatSecure_Push_iOS.framework",
337 | );
338 | runOnlyForDeploymentPostprocessing = 0;
339 | shellPath = /bin/sh;
340 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ChatSecurePushExample/Pods-ChatSecurePushExample-frameworks.sh\"\n";
341 | showEnvVarsInLog = 0;
342 | };
343 | /* End PBXShellScriptBuildPhase section */
344 |
345 | /* Begin PBXSourcesBuildPhase section */
346 | 638C25261B4C43D600AB62CB /* Sources */ = {
347 | isa = PBXSourcesBuildPhase;
348 | buildActionMask = 2147483647;
349 | files = (
350 | 637BAEBA1B5ED006007CC92A /* AccountDetailViewController.swift in Sources */,
351 | 638C25321B4C43D600AB62CB /* ViewController.swift in Sources */,
352 | 638C25301B4C43D600AB62CB /* AppDelegate.swift in Sources */,
353 | );
354 | runOnlyForDeploymentPostprocessing = 0;
355 | };
356 | 638C253B1B4C43D600AB62CB /* Sources */ = {
357 | isa = PBXSourcesBuildPhase;
358 | buildActionMask = 2147483647;
359 | files = (
360 | 638C25461B4C43D600AB62CB /* ChatSecurePushExampleTests.swift in Sources */,
361 | 638C255C1B4C7BB300AB62CB /* URLMockSetup.swift in Sources */,
362 | 63F6DBE11B97AF6E0079E295 /* TestObjects.swift in Sources */,
363 | );
364 | runOnlyForDeploymentPostprocessing = 0;
365 | };
366 | /* End PBXSourcesBuildPhase section */
367 |
368 | /* Begin PBXTargetDependency section */
369 | 638C25411B4C43D600AB62CB /* PBXTargetDependency */ = {
370 | isa = PBXTargetDependency;
371 | target = 638C25291B4C43D600AB62CB /* ChatSecurePushExample */;
372 | targetProxy = 638C25401B4C43D600AB62CB /* PBXContainerItemProxy */;
373 | };
374 | /* End PBXTargetDependency section */
375 |
376 | /* Begin PBXVariantGroup section */
377 | 638C25331B4C43D600AB62CB /* Main.storyboard */ = {
378 | isa = PBXVariantGroup;
379 | children = (
380 | 638C25341B4C43D600AB62CB /* Base */,
381 | );
382 | name = Main.storyboard;
383 | sourceTree = "";
384 | };
385 | 638C25381B4C43D600AB62CB /* LaunchScreen.xib */ = {
386 | isa = PBXVariantGroup;
387 | children = (
388 | 638C25391B4C43D600AB62CB /* Base */,
389 | );
390 | name = LaunchScreen.xib;
391 | sourceTree = "";
392 | };
393 | /* End PBXVariantGroup section */
394 |
395 | /* Begin XCBuildConfiguration section */
396 | 638C25471B4C43D600AB62CB /* Debug */ = {
397 | isa = XCBuildConfiguration;
398 | buildSettings = {
399 | ALWAYS_SEARCH_USER_PATHS = NO;
400 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
401 | CLANG_CXX_LIBRARY = "libc++";
402 | CLANG_ENABLE_MODULES = YES;
403 | CLANG_ENABLE_OBJC_ARC = YES;
404 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
405 | CLANG_WARN_BOOL_CONVERSION = YES;
406 | CLANG_WARN_COMMA = YES;
407 | CLANG_WARN_CONSTANT_CONVERSION = YES;
408 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
409 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
410 | CLANG_WARN_EMPTY_BODY = YES;
411 | CLANG_WARN_ENUM_CONVERSION = YES;
412 | CLANG_WARN_INFINITE_RECURSION = YES;
413 | CLANG_WARN_INT_CONVERSION = YES;
414 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
415 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
416 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
417 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
418 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
419 | CLANG_WARN_STRICT_PROTOTYPES = YES;
420 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
421 | CLANG_WARN_UNREACHABLE_CODE = YES;
422 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
423 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
424 | COPY_PHASE_STRIP = NO;
425 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
426 | ENABLE_STRICT_OBJC_MSGSEND = YES;
427 | ENABLE_TESTABILITY = YES;
428 | GCC_C_LANGUAGE_STANDARD = gnu99;
429 | GCC_DYNAMIC_NO_PIC = NO;
430 | GCC_NO_COMMON_BLOCKS = YES;
431 | GCC_OPTIMIZATION_LEVEL = 0;
432 | GCC_PREPROCESSOR_DEFINITIONS = (
433 | "DEBUG=1",
434 | "$(inherited)",
435 | );
436 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
437 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
438 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
439 | GCC_WARN_UNDECLARED_SELECTOR = YES;
440 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
441 | GCC_WARN_UNUSED_FUNCTION = YES;
442 | GCC_WARN_UNUSED_VARIABLE = YES;
443 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
444 | MTL_ENABLE_DEBUG_INFO = YES;
445 | ONLY_ACTIVE_ARCH = YES;
446 | SDKROOT = iphoneos;
447 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
448 | SWIFT_VERSION = 5.0;
449 | TARGETED_DEVICE_FAMILY = "1,2";
450 | };
451 | name = Debug;
452 | };
453 | 638C25481B4C43D600AB62CB /* Release */ = {
454 | isa = XCBuildConfiguration;
455 | buildSettings = {
456 | ALWAYS_SEARCH_USER_PATHS = NO;
457 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
458 | CLANG_CXX_LIBRARY = "libc++";
459 | CLANG_ENABLE_MODULES = YES;
460 | CLANG_ENABLE_OBJC_ARC = YES;
461 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
462 | CLANG_WARN_BOOL_CONVERSION = YES;
463 | CLANG_WARN_COMMA = YES;
464 | CLANG_WARN_CONSTANT_CONVERSION = YES;
465 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
466 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
467 | CLANG_WARN_EMPTY_BODY = YES;
468 | CLANG_WARN_ENUM_CONVERSION = YES;
469 | CLANG_WARN_INFINITE_RECURSION = YES;
470 | CLANG_WARN_INT_CONVERSION = YES;
471 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
472 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
473 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
474 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
475 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
476 | CLANG_WARN_STRICT_PROTOTYPES = YES;
477 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
478 | CLANG_WARN_UNREACHABLE_CODE = YES;
479 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
480 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
481 | COPY_PHASE_STRIP = NO;
482 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
483 | ENABLE_NS_ASSERTIONS = NO;
484 | ENABLE_STRICT_OBJC_MSGSEND = YES;
485 | GCC_C_LANGUAGE_STANDARD = gnu99;
486 | GCC_NO_COMMON_BLOCKS = YES;
487 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
488 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
489 | GCC_WARN_UNDECLARED_SELECTOR = YES;
490 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
491 | GCC_WARN_UNUSED_FUNCTION = YES;
492 | GCC_WARN_UNUSED_VARIABLE = YES;
493 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
494 | MTL_ENABLE_DEBUG_INFO = NO;
495 | SDKROOT = iphoneos;
496 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
497 | SWIFT_VERSION = 5.0;
498 | TARGETED_DEVICE_FAMILY = "1,2";
499 | VALIDATE_PRODUCT = YES;
500 | };
501 | name = Release;
502 | };
503 | 638C254A1B4C43D600AB62CB /* Debug */ = {
504 | isa = XCBuildConfiguration;
505 | baseConfigurationReference = 1E518B8D8689CA093E280953 /* Pods-ChatSecurePushExample.debug.xcconfig */;
506 | buildSettings = {
507 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
508 | CODE_SIGN_IDENTITY = "iPhone Developer";
509 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
510 | DEVELOPMENT_TEAM = "";
511 | INFOPLIST_FILE = ChatSecurePushExample/Info.plist;
512 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
513 | PRODUCT_BUNDLE_IDENTIFIER = "com.davidchiles.$(PRODUCT_NAME:rfc1034identifier)";
514 | PRODUCT_NAME = "$(TARGET_NAME)";
515 | PROVISIONING_PROFILE = "";
516 | };
517 | name = Debug;
518 | };
519 | 638C254B1B4C43D600AB62CB /* Release */ = {
520 | isa = XCBuildConfiguration;
521 | baseConfigurationReference = 985A1CBBB5BE48DD94C689F6 /* Pods-ChatSecurePushExample.release.xcconfig */;
522 | buildSettings = {
523 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
524 | CODE_SIGN_IDENTITY = "iPhone Developer";
525 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
526 | DEVELOPMENT_TEAM = "";
527 | INFOPLIST_FILE = ChatSecurePushExample/Info.plist;
528 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
529 | PRODUCT_BUNDLE_IDENTIFIER = "com.davidchiles.$(PRODUCT_NAME:rfc1034identifier)";
530 | PRODUCT_NAME = "$(TARGET_NAME)";
531 | PROVISIONING_PROFILE = "";
532 | };
533 | name = Release;
534 | };
535 | 638C254D1B4C43D600AB62CB /* Debug */ = {
536 | isa = XCBuildConfiguration;
537 | baseConfigurationReference = E45F6CD065C806750B98234F /* Pods-ChatSecurePushExampleTests.debug.xcconfig */;
538 | buildSettings = {
539 | BUNDLE_LOADER = "$(TEST_HOST)";
540 | GCC_PREPROCESSOR_DEFINITIONS = (
541 | "DEBUG=1",
542 | "$(inherited)",
543 | );
544 | INFOPLIST_FILE = ChatSecurePushExampleTests/Info.plist;
545 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
546 | PRODUCT_BUNDLE_IDENTIFIER = "com.davidchiles.$(PRODUCT_NAME:rfc1034identifier)";
547 | PRODUCT_NAME = "$(TARGET_NAME)";
548 | SWIFT_OBJC_BRIDGING_HEADER = "ChatSecurePushExampleTests/ChatSecurePushExampleTests-header.h";
549 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatSecurePushExample.app/ChatSecurePushExample";
550 | };
551 | name = Debug;
552 | };
553 | 638C254E1B4C43D600AB62CB /* Release */ = {
554 | isa = XCBuildConfiguration;
555 | baseConfigurationReference = E2D649C3FAACCE12A4DC1C88 /* Pods-ChatSecurePushExampleTests.release.xcconfig */;
556 | buildSettings = {
557 | BUNDLE_LOADER = "$(TEST_HOST)";
558 | INFOPLIST_FILE = ChatSecurePushExampleTests/Info.plist;
559 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
560 | PRODUCT_BUNDLE_IDENTIFIER = "com.davidchiles.$(PRODUCT_NAME:rfc1034identifier)";
561 | PRODUCT_NAME = "$(TARGET_NAME)";
562 | SWIFT_OBJC_BRIDGING_HEADER = "ChatSecurePushExampleTests/ChatSecurePushExampleTests-header.h";
563 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatSecurePushExample.app/ChatSecurePushExample";
564 | };
565 | name = Release;
566 | };
567 | /* End XCBuildConfiguration section */
568 |
569 | /* Begin XCConfigurationList section */
570 | 638C25251B4C43D600AB62CB /* Build configuration list for PBXProject "ChatSecurePushExample" */ = {
571 | isa = XCConfigurationList;
572 | buildConfigurations = (
573 | 638C25471B4C43D600AB62CB /* Debug */,
574 | 638C25481B4C43D600AB62CB /* Release */,
575 | );
576 | defaultConfigurationIsVisible = 0;
577 | defaultConfigurationName = Release;
578 | };
579 | 638C25491B4C43D600AB62CB /* Build configuration list for PBXNativeTarget "ChatSecurePushExample" */ = {
580 | isa = XCConfigurationList;
581 | buildConfigurations = (
582 | 638C254A1B4C43D600AB62CB /* Debug */,
583 | 638C254B1B4C43D600AB62CB /* Release */,
584 | );
585 | defaultConfigurationIsVisible = 0;
586 | defaultConfigurationName = Release;
587 | };
588 | 638C254C1B4C43D600AB62CB /* Build configuration list for PBXNativeTarget "ChatSecurePushExampleTests" */ = {
589 | isa = XCConfigurationList;
590 | buildConfigurations = (
591 | 638C254D1B4C43D600AB62CB /* Debug */,
592 | 638C254E1B4C43D600AB62CB /* Release */,
593 | );
594 | defaultConfigurationIsVisible = 0;
595 | defaultConfigurationName = Release;
596 | };
597 | /* End XCConfigurationList section */
598 | };
599 | rootObject = 638C25221B4C43D600AB62CB /* Project object */;
600 | }
601 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
676 |
--------------------------------------------------------------------------------