nnn

NNNetwork

Networking categories, OAuth and read later clients. Built atop the fabulous AFNetworking.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

43

Maintenance

Last Commit

8yrs ago

Contributors

4

Package

Dependencies

2

License

MIT

Categories

Readme

NNNetwork

NNNetwork is a collection of classes that power networking in Postr. It is built atop AFNetworking and it provides categories for networking, OAuth 1.0 utilities and read later integration classes.

Interacting with OAuth 1.0 Services

NNOAuth class provides a single point to generate an OAuth 1.0 HTTP authorization header. You can also use a NSURLRequest(NNNetwork) category to copy a request and sign it or NSMutableURLRequest(NNNetwork) category to sign an existing request. NNNetwork features a NNOAuth1Client which extends AFHTTPClient to enable interaction with an OAuth service. It defines custom methods for making signed requests from relative paths of a base URL. You can also define your own OAuth clients (eg. for OAuth 2.0) by sublassing NNOAuthClient and overriding signRequest:withParameters:credential:. You use NNOAuthClient subclasses just as you would use an AFHTTPClient subclass:

SomeOAuthClientSublass *client = [SomeOAuthClientSublass sharedClient];
client.clientIdentifier = @"your-app-identifier";
client.clientSecret = @"your-app-secret";

NNOAuthCredential *credential = [NNOAuthCredential credentialWithAccessToken:@"user-token" accessSecret:@"user-secret"];

[client signedGetPath:@"some-endpoint" parameters:nil credential:credential success:^(AFHTTPRequestOperation *operation, id responseObject){
    // Handle success.
} failure:^(AFHTTPRequestOperation *operation, NSError *error){
    // Handle failure.
}];

Interacting with Read Later Services

NNNetwork defines clients for Instapaper, Pocket and Readability, that currently enable you to send an URL to a reading list. These classes extend NNOAuth1Client and conform to NNReadLaterClient protocol for consistency. NNNetwork supports Instapaper, Pocket and Readability. It also provides counterpart UIActivity subclasses. They come along with image resources for UIActivityController. Here's how you would present an activity view controller with Instapaper support from a view controller in iOS 6:

[[NNInstapaperClient sharedClient] setClientIdentifier:@"your-instapaper-app-identifier"];
[[NNInstapaperClient sharedClient] setClientSecret:@"your-instapaper-app-secret"];
NNOAuthCredential *credential = [NNOAuthCredential credentialWithAccessToken:@"user-token" accessSecret:@"user-secret"];

NSURL *readLaterURL = [NSURL URLWithString:@"http://github.com/tomazsh/NNNetwork"];
NNInstapaperActivity *activity = [[NNInstapaperActivity alloc] initWithCredential:credential];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[readLaterURL] applicationActivities:@[activity]];
[self presentViewController:controller animated:YES completion:nil];

Hacker News Demo App

NNNetwork comes with a demo app that demostrates how you would use read later clients and activites to provide read later support in a simple app that fetches articles from Y Combinator's Hacker News.

Documentation

Detailed documentation is available here.

Requirements

NNNetwork requires iOS 5.0 and uses ARC. You can use all categories and sign OAuth requests. Read later activites require iOS 6.0. For OAuth client support and reading list integration NNNetwork requires AFNetworking. Making OAuth credentials keychain friendly requires SSKeychain.

Known Issues

There is currently no support for OAuth 1.0 RSA-SHA1 signing algorithm. There is also no OAuth 2.0 support whatsoever.

License

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100