Rownd bindings for Android
build.gradle
file and add the following dependency:
consumer-rules.pro
file, which should automatically augment your app’s own proguard/r2 config.
If you’re using ProGuard to shrink, obfuscate, and/or optimize your app (and you should!), and you’re noticing minification or runtime errors after installing Rownd, you may need to add the following rules to your proguard-rules.pro
file.
Application
class and pass the app’s primary context.
To initialize Rownd, call the configure method like this:
Application
class:
Rownd.requestSignIn()
at some point, if the user is not already authenticated. This will display the Rownd interface for authenticating the user. Once they complete the sign-in process, an access token and the user’s profile information will be available to your app.
Rownd.state.collectAsState()
, you can use the various parts of the state tree as needed.
Access the state like this:
RowndCustomizations
class exists to facilitate these customizations. It provides the following properties that may be subclassed or overridden.
sheetBackgroundColor: Color?
(default: null
) - Allows setting a single color for Rownd-provided bottom sheet interfaces regardless of system theme. Use this or dynamicSheetBackgroundColor
, but not both.
dynamicSheetBackgroundColor: Color
(default: light: #ffffff
, dark: #1c1c1e
; requires subclassing) - Allows changing the background color underlying the bottom sheet that appears when signing in, managing the user account, etc. Based on the system color scheme.
sheetCornerBorderRadius: Dp
(default: 25.dp
) - Modifies the curvature radius of the bottom sheet’s top corners.
loadingAnimation: Int
(default: null) - Replace Rownd’s use of the system default loading spinner (i.e., ProgressBar
) with a custom animation. Any animation resource compatible with Lottie should work, but will be scaled to fit a 1:1 aspect ratio (usually with a frame width/height of 100 Dp
) This should be a value like R.raw.my_animation
RowndCustomizations
class. Here’s an example:
with
argument, bypassing the authentication method selector. For example, this could be used to steer a new user toward a specific sign-in method.
Supported options:
RowndSignInHint.Google
- Prompt user to sign in with their Google account
RowndSignInHint.OneTap
- Prompt user to sign into their account with Google One Tap
RowndSignInHint.Passkey
- Prompt user to sign in with a passkey if they’ve previously set one up
RowndSignInHint.Guest
- Sign in the user anonymously as a guest.
intent: RowndSignInIntent
- This option applies only when you have opted to split the sign-up/sign-in flow via the Rownd dashboard. Valid values are .SignIn
or .SignUp
. If you don’t set this value, the user will be presented with the unified sign-in/sign-up flow. Please reach out to support@rownd.io to enable.
postSignInRedirect: String
(Not recommended) - If you’ve followed the steps to enable Android App Links, the redirect will be handled automatically. When the user completes the authentication challenge via email or SMS, they’ll be redirected to the URL set for postSignInRedirect. If this is an Android App Link, it will redirect the user back to your app.
RowndSignOutScope.all
- All devices
Any
as the value of a field. However, that value must be serializable using Kotlin’s Serialization library. If the value is not serializable out of the box, you’ll need to provide your own serializer implementation as described in the Kotlin documentation.null
if an access token cannot be returned, either because the user is not signed in or because the refresh token is invalid.
If an access token cannot be returned due to a temporary condition (e.g., inaccessible network), this function will throw a RowndException
indicating the failure reason (e.g., server or network error).
You may also set throwIfMissing
to true
to force an error to be thrown if an access token cannot be returned. This will provide more granular reasons for the failure. The possible error subtypes for RowndException
in this case are:
NoAccessTokenPresentException(message: String)
- the user is not signed inInvalidRefreshTokenException(message: String)
- the refresh token was invalid (e.g., the token was expired, revoked, or a previous exchange failed to complete successfully). The user will be signed out.NetworkConnectionFailureException(details: String)
- a network condition prevented the token from being refreshed, even after several retries and should be re-attempted later. The user can remain signed-in.ServerException(details: String)
- an error occurred on the server and you should try again later. The user can remain signed-in.null
if the token could not be validated and exchanged. If that occurs, it’s likely
that the user should sign-in normally via Rownd.requestSignIn()
.
NOTE: This API is typically used once. After a Rownd token is available, other tokens should be discarded.Example:
"id"
is a special case that will return the user’s ID, even though it’s technically not in the Map itself.
Your application code is responsible for knowing which type the value should cast to. If the cast fails or the entry doesn’t exist, a null
value will be returned.
encrypted
will be encrypted on-device prior to storing in Rownd’s platform.
encrypted
, it will be encrypted on-device prior to storing in Rownd’s platform.
encrypted
are encrypted on-device prior to storing within Rownd. Some identifying fields like email and phone number do not support on-device encryption at this time, since they are frequently used for indexing purposes.
Of course, all data within the Rownd platform is encrypted at rest on disk and in transit, but this does not afford the same privacy guarantees as data encrypted on a user’s local device. For especially sensitive data, we recommend enabling field-level encryption.
data
using the user’s symmetric encryption key and returns the ciphertext as a string. You can encrypt anything that can be represented as a string (e.g., Int, Dictionary, Array, etc), but it’s currently up to you to get it into a string format first.
If the encryption fails, an EncryptionException
will be thrown with a message explaining the failure.
data
, returning the plaintext as a string. If the data originated as some other type (e.g., Map), you’ll need to decode the data back into its original type.
If the decryption fails, an EncryptionException
will be thrown with a message explaining the failure.
Rownd.user.isEncryptionPossible(): Boolean
prior to calling encrypt()
or decrypt()
.RowndEvent
object to Rownd.addEventListener()
. It might look something like this:
Rownd.removeEventListener()
with the same function or closure if you assign it to a variable.
Once the event handler is registered, it will receive events as they occur. The RowndEvent
object contains the event type and any associated data. The event types are defined in the RowndEventType
enum.
NOTE: You’ll needimplementation "org.jetbrains.kotlinx:kotlinx-serialization-json"
listed as a dependency in yourbuild.gradle
file in order to access thedata
JsonObject
in theRowndEvent
object.
Event | Type | Payload |
---|---|---|
User started signing in | RowndEventType.SignInStarted | |
User signed in successfully | RowndEventType.SignInCompleted | |
User sign in failed | RowndEventType.SignInFailed |