Interacting with Stitch
The Stitch
utility class and the rest of the protocols here provide functionality for interacting with a MongoDB Stitch application. None of these classes or protocols are meant to be instantiated directly. All interaction with Stitch begins at the level of the Stitch
utility class.
-
Stitch
is the singleton class with static utility functions for initializing the SDK.Use it to initialize and retrieve a
See moreStitchAppClient
for your Stitch app.Declaration
Swift
public class Stitch
-
The
StitchAppClient
has the fundamental set of methods for communicating with a MongoDB Stitch application backend.An implementation can be initialized or retrieved using the
Stitch
utility class.This protocol provides access to the
StitchAuth
for login and authentication.Using
serviceClient
, you can retrieve services, including theRemoteMongoClient
for reading and writing on the database. To create aRemoteMongoClient
, passremoteMongoClientFactory
intoserviceClient(fromFactory:withName)
.You can also use it to execute Stitch Functions.
Finally, its
See moreStitchPush
object can register the current user for push notifications.Declaration
Swift
public protocol StitchAppClient
-
The
StitchAuth
provides methods for retrieving or modifying the authentication state of aStitchAppClient
.Each
StitchAppClient
has an instance of StitchAuth.Information about the logged-in
StitchUser
is available in thecurrentUser
property.To watch for auth events, add a
See moreStitchAuthDelegate
.Declaration
Swift
public protocol StitchAuth
-
StitchAuthDelegate
is a protocol to be inherited when you need to take action on authentication events. An instance of aStitchAuthDelegate
must be added to aStitchAuth
.Note
This protocol uses an extension to provide default implementations. This is for your convenience, so you do not have to implement every method here to satisfy the protocol requirements. This however does mean that if you plan on subclassing your implementation of
StitchAuthDelegate
, you may run into unexpected issues where the empty default implementation is called instead of your subclass implementation. If this does happen in your code, see this article for more context and potential workarounds, or open an issue in our GitHub repository.- Tag: StitchAuthDelegate
Declaration
Swift
public protocol StitchAuthDelegate : AnyObject
-
StitchPush can be used to get clients that can register for push notifications via Stitch.
See moreDeclaration
Swift
public protocol StitchPush
-
StitchServiceClient acts as a general purpose client for working with services that are not defined or well defined by this SDK. It has methods similar to the
See morecallFunction
method onStitchAppClient
.Declaration
Swift
public protocol StitchServiceClient
-
The
StitchUser
represents the the user who is logged in to theStitchAppClient
.You can retrieve an instance from
StitchAuth
or from theStitchResult
of certain methods.You will find information about the user such as name and email address in the
StitchUserProfile
propertyprofile
.See also
StitchAuth
Declaration
Swift
public protocol StitchUser : CoreStitchUser
-
The StitchUserProfile describes a
StitchUser
.Every
StitchUser
has aStitchUserProfile
member.See
See moreExtendedStitchUserProfile
for additional fields available on this type.Declaration
Swift
public protocol StitchUserProfile : ExtendedStitchUserProfile
-
The
See moreStitchUserIdentity
represents an identity that aStitchUser
is linked to and can use to log in to their account.Declaration
Swift
public protocol StitchUserIdentity : Decodable, Encodable
-
StitchResult
holds the result to an asynchronous operation performed against the Stitch server.When an operation completes successfully, the
See moreStitchResult
holds the result of the operation. When the operation fails, theStitchResult
contains aStitchError
object describing the reason for the failure.Declaration
Swift
public enum StitchResult<T>