DDPClient
public class DDPClient : NSObject
-
Sends a subscription request to the server.
Declaration
Swift
public func subscribe(name:String) -> String { return sub(name, params:nil) }
Parameters
name
The name of the subscription
-
Sends a subscription request to the server.
Declaration
Swift
public func subscribe(name:String, params:[AnyObject]) -> String { return sub(name, params:params) }
Parameters
name
The name of the subscription
params
An object containing method arguments, if any
-
Sends a subscription request to the server. If a callback is passed, the callback asynchronously runs when the client receives a ‘ready’ message indicating that the initial subset of documents contained in the subscription has been sent by the server.
Declaration
Swift
public func subscribe(name:String, params:[AnyObject]?, callback: DDPCallback?) -> String { return sub(name, params:params, callback:callback) }
Parameters
name
The name of the subscription
params
An object containing method arguments, if any
callback
The closure to be executed when the server sends a ‘ready’ message
-
Sends a subscription request to the server. If a callback is passed, the callback asynchronously runs when the client receives a ‘ready’ message indicating that the initial subset of documents contained in the subscription has been sent by the server.
Declaration
Swift
public func subscribe(name:String, callback: DDPCallback?) -> String { return sub(name, params:nil, callback:callback) }
Parameters
name
The name of the subscription
callback
The closure to be executed when the server sends a ‘ready’ message
-
Asynchronously inserts a document into a collection on the server
Declaration
Swift
public func insert(collection: String, document: NSArray, callback: DDPMethodCallback?) -> String
Parameters
collection
The name of the collection
document
An NSArray of documents to insert
callback
A closure with result and error arguments describing the result of the operation
-
Asynchronously inserts a document into a collection on the server
Declaration
Swift
public func insert(collection: String, document: NSArray) -> String
Parameters
collection
The name of the collection
document
An NSArray of documents to insert
-
Synchronously inserts a document into a collection on the server. Cannot be used on the main queue.
Declaration
Swift
public func insert(sync collection: String, document: NSArray) -> Result
Parameters
collection
The name of the collection
document
An NSArray of documents to insert
-
Asynchronously updates a document into a collection on the server
Declaration
Swift
public func update(collection: String, document: NSArray, callback: DDPMethodCallback?) -> String
Parameters
collection
The name of the collection
document
An NSArray of documents to update
callback
A closure with result and error arguments describing the result of the operation
-
Asynchronously updates a document on the server
Declaration
Swift
public func update(collection: String, document: NSArray) -> String
Parameters
collection
The name of the collection
document
An NSArray of documents to update
-
Synchronously updates a document on the server. Cannot be used on the main queue
Declaration
Swift
public func update(sync collection: String, document: NSArray) -> Result
Parameters
collection
The name of the collection
document
An NSArray of documents to update
-
Asynchronously removes a document on the server
Declaration
Swift
public func remove(collection: String, document: NSArray, callback: DDPMethodCallback?) -> String
Parameters
collection
The name of the collection
document
An NSArray of documents to remove
callback
A closure with result and error arguments describing the result of the operation
-
Asynchronously removes a document into a collection on the server
Declaration
Swift
public func remove(collection: String, document: NSArray) -> String
Parameters
collection
The name of the collection
document
An NSArray of documents to remove
-
Synchronously removes a document into a collection on the server. Cannot be used on the main queue.
Declaration
Swift
public func remove(sync collection: String, document: NSArray) -> Result
Parameters
collection
The name of the collection
document
An NSArray of documents to remove
-
Logs a user into the server using an email and password
Declaration
Swift
public func loginWithPassword(email: String, password: String, callback: DDPMethodCallback?)
Parameters
email
An email string
password
A password string
callback
A closure with result and error parameters describing the outcome of the operation
-
Attempts to login a user with a token, if one exists
Declaration
Swift
public func loginWithToken(callback: DDPMethodCallback?) -> Bool
Parameters
callback
A closure with result and error parameters describing the outcome of the operation
-
Undocumented
Declaration
Swift
public class DDPClient : NSObject
-
Invokes a Meteor method to create a user account with a given email and password on the server
Declaration
Swift
public func signupWithEmail(email: String, password: String, callback: ((result:AnyObject?, error:DDPError?) -> ())?)
-
Invokes a Meteor method to create a user account with a given email and password, and a NSDictionary containing a user profile
Declaration
Swift
public func signupWithEmail(email: String, password: String, profile: NSDictionary, callback: ((result:AnyObject?, error:DDPError?) -> ())?)
-
Returns the client userId, if it exists
Declaration
Swift
public func userId() -> String?
-
Returns the client’s username or email, if it exists
Declaration
Swift
public func user() -> String?
-
Logs a user out and removes their account data from NSUserDefaults
Declaration
Swift
public func logout()
-
Logs a user out and removes their account data from NSUserDefaults. When it completes, it posts a notification: DDP_USER_DID_LOGOUT on the main queue
Declaration
Swift
public func logout(callback:DDPMethodCallback?)
Parameters
callback
A closure with result and error parameters describing the outcome of the operation
-
Automatically attempts to resume a prior session, if one exists
Declaration
Swift
public func resume(url:String, callback:DDPCallback?)
Parameters
url
The server url
-
Connects and logs in with an email address and password in one action
Declaration
Swift
public convenience init(url: String, email: String, password: String, callback: DDPMethodCallback?)
Parameters
url
String url, ex. wss://todos.meteor.com/websocket
email
String email address
password
String password
callback
A closure with result and error parameters describing the outcome of the operation
-
Returns true if the user is logged in, and false otherwise
Declaration
Swift
public func loggedIn() -> Bool