-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from dmytrokhl/canary
SDK Pre-release
- Loading branch information
Showing
87 changed files
with
946 additions
and
7,820 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,142 @@ | ||
[![CircleCI](https://circleci.com/gh/verygoodsecurity/vgs-collect-ios/tree/dev.svg?style=svg&circle-token=ec7cddc71a1c2f6e99843ef56fdb6898a2ef8f52)](https://circleci.com/gh/verygoodsecurity/vgs-collect-ios/tree/dev) | ||
[![UT](https://img.shields.io/badge/Unit_Test-pass-green)]() | ||
[![license](https://img.shields.io/github/license/verygoodsecurity/vgs-ios-sdk.svg)]() | ||
[![Platform](https://img.shields.io/cocoapods/p/VGSCollectSDK.svg?style=flat)](https://github.com/verygoodsecurity/vgs-collect-ios) | ||
[![swift](https://img.shields.io/badge/swift-5-orange)]() | ||
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://swift.org/package-manager/) | ||
[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/VGSCollectSDK.svg?style=flat)](https://cocoapods.org/pods/VGSCollectSDK) | ||
|
||
## VGS Collect mobile SDK | ||
# VGS Collect iOS SDK | ||
|
||
VGS Collect - is a product suite that allows customers to collect information securely without possession of it. VGS Collect mobile SDKs - are native mobile forms modules that allow customers to collect information securely on mobile devices with iOS and Android | ||
VGS Collect - is a product suite that allows customers to collect information securely without possession of it. VGSCollect iOS SDK allows you to securely collect data from your users via forms without having to have that data pass through your systems. The form fields behave like traditional input fields while securing access to the unsecured data. | ||
|
||
# Problem | ||
Customers want to use VGS with their native mobile apps on iOS and Android devices. They want to get the same experience that they have on Web with VGS `Collect.js`. | ||
Table of contents | ||
================= | ||
|
||
# Goal | ||
Customers can use the same VGS Vault and the same server-side for Mobile apps as for Web. Their experience should stay the same and be not dependent on the platform they use: Web or Mobile. | ||
<!--ts--> | ||
* [Before you start](#before-you-start) | ||
* [Integration](#integration) | ||
* [CocoaPods](#cocoapods) | ||
* [Swift Package Manager](#swift-package-manager-(-xcode-11+-)) | ||
* [Usage](#usage) | ||
* [Create VGSCollect instance and VGS UI Elements](#create-vgscollect-instance-and-vgs-ui-elements) | ||
* [Customize UI Elements](#customize-ui-elements) | ||
* [Observe Fields State](#observe-fields-state) | ||
* [Collect and Send Your Data](#collect-and-send-your-data) | ||
* [Documentation](#for-more-details-check-our-documentation) | ||
* [Dependencies](#dependencies) | ||
* [License](#license) | ||
<!--te--> | ||
|
||
# Integration | ||
The SDK has simple possibility for integration. For integration need to install the latest version of `cocoapods`. | ||
<p align="center"> | ||
<img src="https://github.com/verygoodsecurity/vgs-collect-ios/blob/canary/vgs-collect-ios-state.png" width="200" alt="VGS Collect iOS SDK State" hspace="20"><img src="https://github.com/verygoodsecurity/vgs-collect-ios/blob/canary/vgs-collect-ios-response.png" width="200" alt="VGS Collect iOS SDK Response" hspace="20"> | ||
</p> | ||
|
||
1. Make a projects on the `xcode` | ||
2. Open the terminal and go to the project folder | ||
3. Make a Podfile (command: `pod init`) | ||
4. Open the Podfile and insert next line | ||
|
||
``` | ||
pod 'VGSCollectSDK' | ||
``` | ||
## Before you start | ||
You should have your organization registered at <a href="https://dashboard.verygoodsecurity.com/dashboard/">VGS Dashboard</a>. Sandbox vault will be pre-created for you. You should use your `<vault-id>` to start collecting data. Follow integration guide below. | ||
|
||
5. Back to terminal and put command `pod install` | ||
6. Open `<your_project_name>.xcworkspace` | ||
7. Open ViewController | ||
8. Put next code to your controller | ||
## Integration | ||
|
||
```` | ||
### CocoaPods | ||
|
||
[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate VGSCollectSDK into your Xcode project using CocoaPods, specify it in your `Podfile`: | ||
|
||
```ruby | ||
pod 'VGSCollectSDK' | ||
``` | ||
|
||
### Swift Package Manager(Xcode 11+) | ||
|
||
[Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. | ||
|
||
To add VGSCollectSDK package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency. Enter package repository URL and press Next: | ||
```ruby | ||
https://github.com/verygoodsecurity/vgs-collect-ios | ||
``` | ||
Now you need to choose which part of the code you want to look at, you can choose the dependency type(tagged version, branch or commit). Then Xcode will setup all the stuff for you. We recommend to choose `master` branch to get latest stable SDK version. | ||
|
||
On Final screen check that you project target is correct and press Finish. | ||
|
||
|
||
|
||
## Usage | ||
|
||
### Create VGSCollect instance and VGS UI Elements | ||
Use your `<vault-id>` to initialize VGSCollect instance. You can get it in your [organisation dashboard](https://dashboard.verygoodsecurity.com/). | ||
``` | ||
import UIKit | ||
import VGSCollectSDK | ||
class ViewController: UIViewController { | ||
var vgsForm = VGSCollect(id: "your_tnt_id", environment: .sandbox) | ||
// VGS UI Elements | ||
var cardNumber = VGSTextField() | ||
var button = UIButton() | ||
// MARK: - Life cycle methods | ||
override func loadView() { | ||
super.loadView() | ||
cardNumber.frame = CGRect(x: 10, y: 55, width: 310, height: 35) | ||
view.addSubview(cardNumber) | ||
} | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
// Observing state of text fields | ||
vgsForm.observeStates = { [weak self] form in | ||
// receiving text fields status | ||
form.forEach { textField in | ||
print(textField.status.description) | ||
} | ||
} | ||
// config text field | ||
let config = VGSConfiguration(collector: vgsForm, fieldName: "cardNumber") | ||
config.type = .cardNumber | ||
config.placeholder = "card number" | ||
cardNumber.configuration = config | ||
// add target for submit button | ||
button.addTarget(self, action: #selector(sendData(_:)), for: .touchUpInside) | ||
} | ||
@objc | ||
func sendData(_ sender: UIButton) { | ||
// send extra data | ||
var extraData = [String: Any]() | ||
extraData["cardHolderName"] = "Joe Business" | ||
// send data | ||
vgsForm.submit(path: "/post", extraData: extraData, completion: { [weak self] (json, error) in | ||
// parse incoming data | ||
}) | ||
} | ||
} | ||
```` | ||
var vgsForm = VGSCollect(id: "<vault-id>", environment: .sandbox) | ||
# Styling your VGS text fields | ||
// VGS UI Elements | ||
var cardNumber = VGSTextField() | ||
You can use general property for customise your text fields. | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
Example: | ||
// Configure Elements UI | ||
let cardConfig = VGSConfiguration(collector: vgsForm, fieldName: "cardNumber") | ||
cardConfig.placeholder = "card number" | ||
cardConfig.isRequired = true | ||
cardConfig.type = .cardNumber | ||
```` | ||
// set UI style | ||
cardNumber.borderWidth = 1 | ||
cardNumber.borderColor = .lightGray | ||
cardNumber.padding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5) | ||
cardNumber.textColor = .magenta | ||
cardNumber.font = UIFont(name: "Arial", size: 22) | ||
```` | ||
cardNumber.configuration = cardConfig | ||
cardNumber.frame = CGRect(x: 10, y: 55, width: 310, height: 35) | ||
view.addSubview(cardNumber) | ||
} | ||
} | ||
``` | ||
### Customize UI Elements | ||
You can use general properties for styling your UI elements. | ||
``` | ||
// UI Elements styling | ||
cardNumber.borderWidth = 1 | ||
cardNumber.borderColor = .lightGray | ||
cardNumber.padding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5) | ||
cardNumber.textColor = .magenta | ||
cardNumber.font = UIFont(name: "Arial", size: 22) | ||
``` | ||
### Observe Fields State | ||
``` | ||
// Observing text fields | ||
vgsForm.observeStates = { textFields in | ||
textFields.forEach({ textField in | ||
print(textField.state.description) | ||
}) | ||
} | ||
``` | ||
### Collect and Send Your Data | ||
``` | ||
func sendData() { | ||
// extra information will be sent together with all sensitive card information | ||
var extraData = [String: Any]() | ||
extraData["cardHolderName"] = "Joe Business" | ||
// send data | ||
vgsForm.submit(path: "/post", extraData: extraData, completion: { (json, error) in | ||
if error == nil, let json = json { | ||
// parse response data | ||
} else { | ||
// handle error | ||
} | ||
}) | ||
} | ||
``` | ||
|
||
### For more details check our documentation | ||
https://www.verygoodsecurity.com/docs/vgs-collect/ios-sdk | ||
|
||
# Technologies what we use: | ||
- Swift 4.2 | ||
- 3th party lib: | ||
## Dependencies | ||
- iOS 10+ | ||
- Swift 5 | ||
- 3rd party libraries: | ||
- Alamofire | ||
- Git, Continuous | ||
- Testing solutions: Unit Tests | ||
|
||
## License | ||
|
||
VGSCollect iOS SDK is released under the MIT license. [See LICENSE](https://github.com/verygoodsecurity/vgs-ios-sdk/blob/master/LICENSE) for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
Pod::Spec.new do |spec| | ||
spec.name = 'VGSCollectSDK' | ||
spec.version = '0.0.3' | ||
spec.summary = 'SDK provides the ability for applications safety to collect selective data (cc, PII) and keep your application out of pic scope' | ||
spec.version = '0.0.4' | ||
spec.summary = 'VGS Collect - is a product suite that allows customers to collect information securely without possession of it.' | ||
spec.swift_version = '5.0' | ||
spec.description = <<-DESC | ||
VGS Collect - is a product suite that allows customers to collect information securely without possession of it. VGS Collect mobile SDKs - are native mobile forms modules that allow customers to collect information securely on mobile devices with iOS | ||
VGS Collect iOS SDK allows you to securely collect data from your users without having to have that data pass through your systems. It provides customizable UI elements for collecting users’ sensitive data securely on mobile devices with iOS. | ||
DESC | ||
spec.homepage = "https://www.verygoodsecurity.com" | ||
# spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" | ||
spec.license = "MIT" | ||
spec.homepage = "https://github.com/verygoodsecurity/vgs-collect-ios" | ||
spec.documentation_url = "https://www.verygoodsecurity.com/docs/vgs-collect/ios-sdk" | ||
spec.license = { type: 'MIT', file: 'LICENSE' } | ||
spec.author = { | ||
"Vitalii Obertynskyi" => "[email protected]", | ||
"Dmytro Khludkov" => "[email protected]" | ||
"Very Good Security" => "[email protected]" | ||
} | ||
spec.social_media_url = "https://twitter.com/miraving" | ||
spec.social_media_url = "https://twitter.com/getvgs" | ||
spec.platform = :ios, "10.0" | ||
spec.ios.deployment_target = "10.0" | ||
# spec.osx.deployment_target = "10.7" | ||
# spec.watchos.deployment_target = "2.0" | ||
# spec.tvos.deployment_target = "9.0" | ||
spec.source = { :git => "https://github.com/verygoodsecurity/vgs-collect-ios.git", :tag => "#{spec.version}" } | ||
spec.source_files = "framework/Sources/VGSFramework", "framework/Sources/VGSFramework/**/*.{swift}" | ||
spec.frameworks = "Alamofire" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.