Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
Jesse Bounds edited this page Dec 15, 2013 · 15 revisions
Under-Construction!!!

Usage

MeteorClient

The MeteorClient public API exposes a simple, cohesive set of methods that describe the communication between a native Objective-C client and a DDP server.

-logonWithUsername:password * DEPRECATED *

This method has been deprecated as of release 0.1.2. Please use logonWithUsername:password:responseCallback: or ~~~ logonWithUserParameters` ~~~ instead.

-logonWithUsername:password:responseCallback:

This method takes a username (email) string, password string, and a MeteorClientMethodCallback block. This method will attempt to logon (via SRP) to the meteor server specified when the MeteorClient was created and, if successful will call the callback so that clients can respond appropriately. If the logon attempt fails for some reason (e.g. not connected to server or bad password) then MeteorClient will call the responseCallback with an error object. It is a convenience wrapper for authorization with meteor servers using the meteor default scheme where the username is a string that represents user's email or system username. If you want to send an object to specify specifically user, username, or id (as per the meteor documentation then you can use _____ instead.

Example:

    [self.meteor logonWithUsername:self.username.text 
                          password:self.password.text 
                  responseCallback:^(NSDictionary *response, NSError *error) {
        if (error) {
            [self handleFailedAuth:error];
            return;
        }
        [self handleSuccessfulAuth];
    }];

-callMethodName:parameters:responseCallback:

This method takes the method name string (the name of the function exposed by the server), an Objective-C array of parameters that are to be passed to the server function and an optional MeteorClientMethodCallback block that will be invoked after the server returns the result of running the function.

Example:

    [self.meteor callMethodName:@"sayHelloTo" parameters:@[self.username.text] responseCallback:^(NSDictionary *response, NSError *error) {
        NSString *message = response[@"result"];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Meteor Todos"
                                                        message:message
                                                       delegate:nil
                                              cancelButtonTitle:@"Great"
                                              otherButtonTitles:nil];
        [alert show];
    }];

MeteorClientMethodCallback

This is a block defined as:

typedef void(^MeteorClientMethodCallback)(NSDictionary *response, NSError *error);

It describes a callback block that can optionally be passed to several MeteorClient methods. The methods that take this block will resolve it with either a success response or a failure error (see method descriptions above).

Clone this wiki locally