Releases: mongodb/stitch-android-sdk
Release 4.1.0
In this release we have released the beta of Stitch Mobile Sync! Documentation to follow shortly.
Release 4.0.5
- Added generic AWS service
- New Packages:
org.mongodb:stitch-android-services-aws
org.mongodb:stitch-server-services-aws
- New Packages:
- Exposed StitchServiceClient to support services which are not well-defined by the SDK
Release 3.0.0
Usage of StitchClient
StitchClient
can longer be constructed directly. Instead, StitchClientFactory
has been introduced to asynchronously perform any initialization steps needed to create a StitchClient
. StitchClientFactory
has a function called create
that will return a Task
that will resolve with a StitchClient
after initialization. The resolved client should be used for the lifetime of the application.
Migration Path
// old, 2.x.x usage
import com.mongodb.stitch.android.StitchClient;
void init() {
StitchClient stitchClient = StitchClient(appId: "<app-id>");
stitchClient.logInWithProvider(new AnonymousAuthProvider())
.addOnSuccessListener(new OnSuccessListener<String>() {
@Override
public void onSuccess(String userId) {
Log.d("MyApp", userId);
}
});
}
// new, 3.x.x usage
import com.mongodb.stitch.android.StitchClientFactory;
StitchClient stitchClient = null;
void init() {
StitchClientFactory.create(context, "<appId>")
.continueWith(new Continuation<StitchClient, Task<String>>() {
@Override
public Task<String> then(@NonNull Task<StitchClient> task) throws Exception {
stitchClient = task.getResult();
return stitchClient.logInWithProvider(new AnonymousAuthProvider());
}
}).addOnSuccessListener(new OnSuccessListener<Task<String>>() {
@Override
public void onSuccess(Task<String> userIdTask) {
initializeApp(stitchClient);
}
});
}
Since the StitchClient
is only available after the Task resolves, initialization of an app should be deferred until this time and the client reference should be passed to some initialization component/function.
NOTE: Attempting to construct a StitchClient
without using StitchClientFactory
will result in an error being thrown.
Authentication
Previously, logging in with a provider while already logging caused no log in to happen which proved to be confusing. These new semantics are in effect:
- Authenticating multiple times with anonymous authentication while already authenticated anonymously does nothing and returns the current user ID.
- Authenticating with any provider but anonymous will log out the current user and then log in with the new provider.
- Add
isAuthenticated()
method to theStitchClient
class. This method should be used to check if any authentication work needs to happen. It returns a boolean declaring whether or not the current client is authenticated.