GithubHelp home page GithubHelp logo

dayton1987 / uploadcare-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uploadcare/uploadcare-ios

0.0 1.0 0.0 12.22 MB

UploadcareKit: iOS SDK for Uploadcare API

Home Page: http://uploadcare.com/

License: MIT License

Objective-C 93.66% Ruby 0.36% Shell 5.98%

uploadcare-ios's Introduction

Uploadcare for iOS

Uploadcare is a PaaS, providing file handling mechanisms for web sites and mobile applications.

Uploadcare for iOS is an open source Objective-C component that brings Uploadcare features to your iOS apps. It consists of two general parts: UploadcareKit and Uploadcare Widget.

UploadcareKit is a core-level abstract layer, responsible for API communication within upload and download tasks.

Uploadcare Widget, a major component of Uploadcare for iOS, is what a modern, cloud-aware file picker for iOS would be, if iOS had a notion of files. Since iOS doesn't, you can think of Uploadcare Widget as a thing picker โ€“ a drop-in component, that allows your users to select and upload their things (photos, documents, whatever you want them to) to your service, via Uploadcare.

Here's what it looks like:

Uploadcare for iOS menu Facebook albums Instagram gallery

Quickstart

Install

Uploadcare for iOS uses CocoaPods, a library dependency management tool for Objective-C projects. To install Uploadcare for iOS in your project, just add the following line to your Podfile:

pod 'Uploadcare'

Then, run pod install in your project directory.

Make sure to use the .xcworkspace file from now on.

Setup

Environment

Import Uploadcare.h header to your implementation. Set up uploadcare public key as following in your application delegate:

#import <Uploadcare/Uploadcare.h>

/* ... */

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[UCClient defaultClient] setPublicKey:<#your key#>];
    return YES;
}

iCloud entitlements

Uploadcare widget uses UIDocumentMenuViewController, so you need to enable iCloud in your application. Go to Target -> Capabilities and enable iCloud. Set both Key-value storage and iCloud Documents options enabled: iCloud settings

Custom url scheme

Uploadcare widget uses SFSafariViewController on iOS 9+ and UIWebView on prior versions for authentification. In this case it should handle url callbacks through custom url scheme from application delegate methods:

// IOS 9+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
    return [[UCClient defaultClient] handleURL:url];
}

// IOS 8
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [[UCClient defaultClient] handleURL:url];
}

In order to add custom url scheme, perform the following steps:

  • Go to Target -> Info -> URL types
  • Add new url scheme with the following format: uc-<public key>
  • The final result should look similar to this:

Custom url scheme

NSPhotoLibraryUsageDescription on iOS 10

Uploadcare widget uses UIImagePickerController to upload files from camera roll. Don't forget to add NSPhotoLibraryUsageDescription key to your project Info.plist file to prevent app from crash in runtime.

Show

Init and present widget

To display the Uploadcare Widget, you must create and initialize an instance of UCMenuViewController by invoking initWithProgress:completion: method:

#import <Uploadcare/Uploadcare.h>

/* ... */

UCMenuViewController *menu = [[UCMenuViewController alloc] initWithProgress:^(NSUInteger bytesSent, NSUInteger bytesExpectedToSend) {
    // handle progress here
} completion:^(NSString *fileId, id response, NSError *error) {
    if (!error) {
        // handle success
    } else {
        // handle error
    }
}];
    
    

Then, present it with presentFrom: method:

[menu presentFrom:self];

Customization

You can easily customize your social networks list apperance by implementing your own menu. In order to receive available social sources, you can use fetchSocialSourcesWithCompletion: method from UCSocialManager. After you receive a list of social sources, you can choose one and use it for instantiating UCGalleryVC with the following method:

- (id)initWithSource:(UCSocialSource *)source
           rootChunk:(UCSocialChunk *)rootChunk
            progress:(UCProgressBlock)progress
          completion:(UCWidgetCompletionBlock)completion;

Core level features only

In order to integrate core level features only, such as local and remote file upload operations, you can use the following subspec:

pod 'Uploadcare/Core'

Please notice, that Uploadcare.h header won't be included in this case, so you'll have to use UploadcareKit.h instead.

Sample App

Please take a look at the Example Project.

Contact

If you have any questions, bug reports or suggestions, drop us a line.

License

Uploadcare iOS is licensed under the MIT license (see LICENSE).

uploadcare-ios's People

Contributors

zrxq avatar ynechaev avatar dive avatar rusik avatar dmitry-mukhin avatar markbao avatar homm avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.