Commit c7b234a9 authored by Prakhar Agrawal's avatar Prakhar Agrawal
Browse files

Added support to download files and Kepler events.

Updated READme.

Updated podspec file.
parent fb36317b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
Pod::Spec.new do |s|

  s.name         = "Leegality"
  s.version      = "1.1.1"
  s.version      = "1.1.2"
  s.summary      = "Leegality framework to integrate eSigning functionality in iOS apps."
  s.homepage     = "https://www.leegality.com"
  s.license      = "MIT"
  s.author       = "Prakhar Agrawal"
  s.platform     = :ios, "11.0"
  s.source       = { :git => "http://gitlab.leegality.com/leegality-public/ios-sdk.git", :tag => "1.1.1" }
  s.source       = { :git => "http://gitlab.leegality.com/leegality-public/ios-sdk.git", :tag => "1.1.2" }
  s.source_files     = "Leegality", "Leegality/**/*.{h,m,swift}"

end
+33 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import WebKit

public protocol LeegalityProtocol {
    func getResult(value : [String : String])
    func getAlert(value : [String : String])
}

public class Leegality: UIViewController, WKUIDelegate, WKNavigationDelegate {
@@ -103,6 +104,22 @@ public class Leegality: UIViewController, WKUIDelegate, WKNavigationDelegate {
            delegate?.getResult(value: dict)
            self.dismiss(animated: true, completion: nil)
        }
        if scheme == "leegalityDownload" {
            let string = url.absoluteString
            let strings = string.components(separatedBy: "://")[1].components(separatedBy: ":")
            let name = strings[0].removingPercentEncoding!
            let file  = strings[1].removingPercentEncoding!
            savePdf(name,file)
        }
        if scheme == "triggerKeplerEvent" {
            let string = url.absoluteString
            var strings = string.components(separatedBy: "://")[1].components(separatedBy: ":")
            var dict = [String: String]()
            let name = strings.removeFirst()
            let jsonString = strings.joined()
            dict[name] = jsonString.removingPercentEncoding!
            delegate?.getAlert(value: dict)
        }
    }
    
    private func configureButtons() {
@@ -110,7 +127,22 @@ public class Leegality: UIViewController, WKUIDelegate, WKNavigationDelegate {
    }

    @objc private func didTapButton() {
        delegate?.getResult(value: ["message":"Cancelled"])
        delegate?.getResult(value: ["message":"Cancelled."])
        dismiss(animated: true, completion: nil)
    }
    
    func savePdf(_ name : String, _ base64File: String) {
        let fileManager = FileManager.default
        let paths = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent(name)
        let pdfDoc = NSData(base64Encoded: base64File, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters)
        fileManager.createFile(atPath: paths as String, contents: pdfDoc as Data?, attributes: nil)
        if fileManager.fileExists(atPath: paths){
            let documento = NSData(contentsOfFile: paths)
            let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [documento!], applicationActivities: nil)
            activityViewController.popoverPresentationController?.sourceView = self.view
            present(activityViewController, animated: true, completion: nil)
         } else {
             print("document was not found")
         }
    }
}
 No newline at end of file
+35 −2
Original line number Diff line number Diff line
### Steps to Use ###

1.  Use following pod profile: 
	<br __>pod ‘Leegality’, :git => ‘http://gitlab.leegality.com/leegality-public/ios-sdk.git’, :tag => ‘1.1.1
	<br __>pod ‘Leegality’, :git => ‘http://gitlab.leegality.com/leegality-public/ios-sdk.git’, :tag => ‘1.1.2
2. Import Leegality on the top of the class.
3. Extend LeegalityProtocol in your ViewController class to get the response as result.
4. Create getResult method of LeegalityProtocol as shown below:
@@ -11,7 +11,14 @@
		print(value)
	}
	```
5. To start the signing process, follow the below code:
5. Create getAlert method of LeegalityProtocol as shown below:
	```
	func getAlert(value: [String : String]) {
		//your code here
		print(value)
	}
	```
6. To start the signing process, follow the below code:
	```
	let controller = Leegality(url: "your-signing-url")
	controller.delegate = self
@@ -23,3 +30,29 @@

1. In case of successfully completion of signing process, signing window will be closed automatically and you will get a response with key name 'message' and corresponding 'success message' in the getResult method.
2. In case of error in signing process, signing window will be closed automatically and you will get a response with key name 'error' and corresponding 'error message'.

### Alert: ###

All the events triggered which pops up in the front end will be received in this getAlert callback method in string format which can then be parsed into JSON. The structure of the JSON is mentioned below.

### JSON Structure: ###

Broadcast event JSON structure:

```
{
	"invitationId":"string",
	"eventName":"string",
	"sessionId":"string",
	"data":{
		"notificationRaised":{
			"messages":[
			{
				"code":"string",
				"message":"string"
			}],
		"type":"string"
		}
	}
}
```
 No newline at end of file