MendeleySDK 2.1.4

MendeleySDK 2.1.4

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2016

Maintained by Vincent Tourraine.



Objective-C client for the Mendeley API.

MendeleySDK is a Mendeley API client for iOS and OS X, built on top of AFNetworking and AFOAuth2Client.

Demo app screenshot paper

Getting Started

Installation

CocoaPods is the recommended way to add MendeleySDK to your project.

Here’s an example podfile that installs MendeleySDK and its dependency, AFOAuth2Client.

platform :ios, '5.0'

pod 'MendeleySDK', '~> 2.1'

App credentials

Configure your API client by calling clientWithClientID:secret:redirectURI: with your application client ID, client secret, and redirect URI (in your application:didFinishLaunchingWithOptions:, for instance):

MDLMendeleyAPIClient *APIClient = [MDLMendeleyAPIClient clientWithClientID:@"###my_client_ID###"
                                                                    secret:@"###my_client_secret###"
                                                               redirectURI:@"###mdl-custom-scheme://oauth?###"];

If you don’t have a consumer key and secret, go to the Mendeley Developers Portal and register your application first.

OAuth authorization flow

Once the API client is configured, you need to present a web browser with a authenticationWebURL request. This page will make sure that your application is properly recognized, and prompt the user for his credentials. You can either use an in-app UIWebView, or open Safari and catch the response with a custom URL scheme.

After being logged in, you’ll get an authorization code. You can then validate this code in order to obtain the access and refresh tokens with validateOAuthCode:success:failure:.

As of today, MendeleySDK doesn’t support the client credentials flow for public resources.

Okay, you should be ready to go now! You can also take a look at the demo apps and see how things work.

Examples

How to create a new document

MDLDocument *document = [[MDLDocument alloc] init];
document.title = @"My Title";
[document createWithClient:self.APIClient success:^(MDLObject *document) {
     /* ... */
} failure:^(NSError *error) {
    /* ... */
}];

How to upload a file

MDLDocument *document;
[document uploadFileWithClient:self.APIClient 
                         atURL:localFileURL
                   contentType:@"application/pdf"
                      fileName:@"file.pdf"
                       success:^(MDLFile *newFile) {
                       /* ... */
                   } 
                   failure:^(NSError *error) {
                   /* ... */
               }];

References

Requirements

MendeleySDK requires Xcode 7.0 with either the iOS 5.0 or OS X 10.7 SDK, as well as AFOAuth2Client.

Credits

MendeleySDK is developed by shazino.

License

MendeleySDK is available under the MIT license. See the LICENSE file for more info.