Latest 0.1.3-beta
Homepage https://github.com/docusign/docusign-ios-sdk
License DOCUSIGN API SDK LICENSE
Platforms ios 7.0, requires ARC
Dependencies AKANetworkLogging, DSTextEntryValidation, Mantle, TPKeyboardAvoiding
Frameworks AVFoundation, CoreLocation, Foundation, ImageIO, MobileCoreServices, QuartzCore, UIKit
Authors

DocuSign iOS SDK Beta

This BETA SDK is built on our public REST API and provides a quick and easy way for developers to add DocuSign’s world-class document signing experience to their native iOS apps.

WARNING: This beta release of the DocuSign iOS SDK is under active development, and the interfaces are still being refined. Please use this in production at your own risk.

Pre-requisites

DocuSign Developer account (Free)

You can create your free dev account at the DocuSign DevCenter using this registration form. You will need the Integrator Key from your developer account in order to use the DocuSign iOS SDK.

Useful Reading

See Common Terms for an explantion of the basic components of the DocuSign platform.

Quickstart Guide

Add the SDK using CocoaPods

CocoaPods is a dependency manager for Objective-C projects. It is distributed as a ruby gem and can be installed using:

$ gem install cocoapods # This may require sudo

Once you have CocoaPods installed, create a file called podfile in the root directory of your Xcode project, and add the following:

platform :ios, '7.0'

pod 'DocuSign-iOS-SDK'

Then in the same directory as your podfile run

$ pod install

This will update or create a workspace that includes the DocuSign iOS SDK and all its dependencies combined with your project. pod install fetches the latest version of the SDK. After installation, you can update all your CocoaPods dependencies using pod update. For more options on how to manage dependencies see the official CocoaPods guide.

NOTE: From now on to run your project you must use the .xcworkspace, NOT the .xcodeproj

Import the Headers

Everything you need in order to use the DocuSign iOS SDK can be imported using the following:

#import <DocuSign-iOS-SDK/DocuSign-iOS-SDK.h>

Authenticate with DocuSign

There are several authentication options, depending on how your workflow integrates with DocuSign.

Present a login view to your user

If the user has a DocuSign account, you can present a DSLoginViewController and receive an authenticated DSSessionManager instance.

First, present the DSLoginViewController:

DSLoginViewController *loginViewController = [[DSLoginViewController alloc] initWithIntegratorKey:@"<#IntegratorKey#>"
                                                                                   forEnvironment:DSRestAPIEnvironmentDemo
                                                                                            email:@"<#email#>" //This will pre-populate the UI
                                                                                         delegate:self];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
[self presentViewController:navController animated:YES completion:nil];

Then implement the DSLoginViewControllerDelegate methods:

- (void)loginViewController:(DSLoginViewController *)controller didLoginWithSessionManager:(DSSessionManager *)sessionManager {
    self.sessionManager = sessionManager;
    [self dismissViewControllerAnimated:YES completion:nil];
    // Make API calls!
}

- (void)loginViewControllerCancelled:(DSLoginViewController *)controller {
    [self dismissViewControllerAnimated:YES completion:nil];
}

Authenticate programmatically

If your app is already integrated with DocuSign, you may have authenticated via some other means. We support two methods of programmatic authentication.

Using a DocuSign OAuth token:

self.sessionManager = [[DSSessionManager alloc] initWithIntegratorKey:@"<#IntegratorKey#>"
                                                       forEnvironment:DSRestAPIEnvironmentDemo
                                                            authToken:@"<#AuthToken#>"
                                                         authDelegate:self];
[self.sessionManager authenticate];

Using a username and password:

self.sessionManager = [[DSSessionManager alloc] initWithIntegratorKey:@"<#IntegratorKey#>"
                                                       forEnvironment:DSRestAPIEnvironmentDemo
                                                             username:@"<#email#>"
                                                             password:@"<#password#>"
                                                         authDelegate:self];
[self.sessionManager authenticate];

When the session manager gets authentication results, it will call back to the delegate specified in authDelegate:, after which you will be able to use the rest of the SDK’s functionality. If the user belongs to more than one DocuSign account, these methods with authenticate with the default account. If you wish to choose a specifc account, implement the optional delegate method -sessionManager:chooseAccountIDFromAvailableAccounts:completeAuthenticationHandler.

Sign a Document (DSSigningViewController)

Get an envelope to sign

If you have created an envelope elsewhere and you already have the envelopeId or recipientId, you can simply present a DSSigningViewController:

DSSigningViewController *signingViewController = [self.sessionManager signingViewControllerForRecipientWithID:@"<#recipientId#>"
                                                                                             inEnvelopeWithID:@"<#envelopeId#>"
                                                                                                     delegate:self];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:signingViewController];
[self presentViewController:navController animated:YES completion:nil];

If you have a file in that needs to be signed, create a DocuSign envelope and present a DSSigningViewController:

[self.sessionManager startCreateSelfSignEnvelopeTaskWithFileName:@"<#NewFileName#>" fileURL:<#LocalFileURL#> completionHandler:^(DSCreateEnvelopeResponse *response, NSError *error) {
    if (error) {
        // Handle the error
        return;
    }
    DSSigningViewController *signingViewController = [self.sessionManager signingViewControllerForRecipientWithID:nil
                                                                                                 inEnvelopeWithID:response.envelopeID
                                                                                                         delegate:self];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:signingViewController];
    [self presentViewController:navController animated:YES completion:nil];
}];

Implement DSSigningViewControllerDelegate

- (void)signingViewController:(DSSigningViewController *)signingViewController completedWithStatus:(DSSigningCompletedStatus)status {
    [self dismissViewControllerAnimated:YES completion:^{
        switch (status) {
            case DSSigningCompletedStatusSigned: {
                // Handle signed envelope
                break;
            }
            case DSSigningCompletedStatusDeferred:
                // Handle deferred envelope
                break;
            case DSSigningCompletedStatusDeclined:
                // Handle declined envelope
                break;
        }
    }];
}

- (void)signingViewController:(DSSigningViewController *)signingViewController failedWithError:(NSError *)error {
    [self dismissViewControllerAnimated:YES completion:^{
        // handle error
    }];
}

License

The DocuSign iOS SDK is licensed under the DOCUSIGN Mobile iOS SDK LICENSE.

Latest podspec

{
    "name": "DocuSign-iOS-SDK",
    "version": "0.1.3-beta",
    "summary": "DocuSign iOS SDK Beta",
    "description": "An iOS SDK that provides a quick and easy way for registered developers to add DocuSign's world-class document signing experience to their native iOS apps.",
    "homepage": "https://github.com/docusign/docusign-ios-sdk",
    "license": "DOCUSIGN API SDK LICENSE",
    "authors": {
        "Arlo Armstrong": "[email protected]"
    },
    "source": {
        "git": "https://github.com/docusign/docusign-ios-sdk.git",
        "tag": "v0.1.3-beta"
    },
    "social_media_url": "https://twitter.com/DocuSignDev",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": [
        "**/SDK/**/*.{h,m}"
    ],
    "resources": [
        "**/SDK/**/*.{storyboard,xcassets}"
    ],
    "frameworks": [
        "AVFoundation",
        "CoreLocation",
        "Foundation",
        "ImageIO",
        "MobileCoreServices",
        "QuartzCore",
        "UIKit"
    ],
    "libraries": "objc",
    "dependencies": {
        "AKANetworkLogging": [
            "~>0.1"
        ],
        "DSTextEntryValidation": [
            "~>1.0"
        ],
        "Mantle": [
            "~>1.4"
        ],
        "TPKeyboardAvoiding": [
            "~>1.2"
        ]
    }
}

Pin It on Pinterest

Share This