Since my last post the Jive iOS SDK has started to be redesigned. But this post is mostly going to be about the new Example project that is part of Jive iOS SDK on github.

 

To start with the example project is designed to only access 1 Jive instance, https://community.jivesoftware.com. Since I already know the URL is valid I skip the version check and go straight to the me call.

From JVJiveFactory.m:

- (void)loginWithName:(NSString *)userName
             password:(NSString *)password
             complete:(JivePersonCompleteBlock)completeBlock
                error:(JiveErrorBlock)errorBlock {
    JiveErrorBlock errorBlockCopy = [errorBlock copy];
   
    self.userName = userName;
    self.password = password;
    self.jive = [[Jive alloc] initWithJiveInstance:[NSURL URLWithString:@"https://community.jivesoftware.com"]
                             authorizationDelegate:self];
    self.credentials = nil;
    [self.jive me:completeBlock
          onError:^(NSError *error) {
              [self handleLoginError:error withErrorBlock:errorBlockCopy];
          }];
}

Here you see the creation of the Jive instance, using the JVJiveFactory as the authorizationDelegate, and the first call to that instance.

 

The next step is to retrieve the list of people being followed.

From JVMasterViewController.m:

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (self.me) {
        _objects = [@[self.me] mutableCopy];
        [self.me followingWithOptions:nil
                           onComplete:^(NSArray *objects) {
                               [self addFollowers:objects];
                           } onError:nil];
    }
}

- (void)addFollowers:(NSArray *)objects {
    [_objects addObjectsFromArray:objects];
    [self.tableView reloadData];
}

I didn't pass in an error handler here. From one perspective it is not necessary as in this instance it can be safely ignored without changing the user experience. But I really didn't put one in as this is an example and it is left to you to implement proper error handling. You will see this repeated throughout the rest of the project.

 

Selecting a person from the list will take you to the blog posts screen. To fill that in we start with one of the newly redesigned methods.

From JVDetailViewController.m:

- (void)setDetailItem:(id)newDetailItem
{
    if (_detailItem != newDetailItem) {
        JivePerson *person = newDetailItem;
        _detailItem = newDetailItem;
        self.title = person.displayName;
        [person blogWithOptions:nil
                     onComplete:^(JiveBlog *blog) {
                         self.blog = blog;
                     } onError:nil];
    }
}

Following the standard storyboard transition pattern, we have a detail item that holds the JivePerson that was selected. From this we retrieve the JiveBlog object by calling the new blogWithOptions:onComplete:onError: method.

This demonstrates the structure that is being added to the SDK. Instead of always using the Jive instance, once you have a valid JiveObject you just call methods directly on that object.

As of this writing JivePerson is the only class that has been updated. But it will soon be joined by the rest of the SDK.

 

Speaking of a method that will soon be replaced. Now that we have loaded the JiveBlog we need to get the JivePosts in the blog.

From JVDetailViewController.m:

- (void)setBlog:(JiveBlog *)blog {
    NSOperation *operation = [[JVJiveFactory jiveInstance] contentsOperationWithURL:blog.contentsRef
                                                                         onComplete:^(NSArray *contents) {
                                                                             [self.activityIndicator stopAnimating];
                                                                             self.tableViewController.contents = contents;
                                                                         } onError:nil];
   
    _blog = blog;
    self.title = blog.name;
    [self.operationQueue addOperation:operation];
    [self.activityIndicator startAnimating];
}

Here we see the contentsOperationWithURL:onComplete:onError: method used to retrieve the JivePosts in the blog. This method will soon be replaced by a JiveBlog method.