Links

Android

Android software development is the process by which applications are created for devices running the Android operating system.

Let's Get your Android App running with SAWO
🙌

Requirements

Steps

1. Add the following line to the root of setting.gradle repositories block.
maven { url 'https://jitpack.io' }
2. Add this to your app level build.gradle android block.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
3. Add this to your app level build.gradle dependencies block
implementation 'com.github.sawolabs:Android-SDK:0.3.0'
Add this to your app level build.gradle defaultConfig block
minSdkVersion 24
4. Sync your project.
5. To use SAWO Login you would need an API key which can be obtained by creating a project in the sawo dashboard.
6. Copy the API key from the project and keep it safe and secure.
The best practice to store your API key is to store values in .env so that they are not exposed.
7. Create an Activity in Android Studio to get login success response for this example lets assume it is CallbackActivity.
8. In your MainActivity add a button to login and add following code to its onclick handle.
Java
import com.sawolabs.androidsdk.Sawo;
public void onClickLogin(View view) {
new Sawo(
this,
"", // your api key
"" // your api key secret
).login(
"email", // can be one of 'email' or 'phone_number_sms' or 'both_email_phone'
CallbackActivity.class.getName() // Callback class name
);
}
Kotlin
import com.sawolabs.androidsdk.Sawo
fun onClickLogin(view: View) {
Sawo(
this,
"", // your api key
"" // your api key secret
).login(
"email", // can be one of 'email' or 'phone_number_sms' or 'both_email_phone'
CallbackActivity::class.java.name // Callback class name
)
}
10. Get the response payload in the CallbackActivity
Java
import com.sawolabs.androidsdk.ConstantsKt;
Intent intent = getIntent();
String message = intent.getStringExtra(ConstantsKt.LOGIN_SUCCESS_MESSAGE);
// continue with your implementation
Kotlin
import com.sawolabs.androidsdk.LOGIN_SUCCESS_MESSAGE
val message = intent.getStringExtra(LOGIN_SUCCESS_MESSAGE)
// continue with your implementation
Once the SAWO SDK is successfully set up, a login form will be rendered in the provided container as displayed in the picture below:

Congratulations !! The SAWO API is now ready to be used in your Android application 🤘.

You can also check out SAWO's
Android Sample Kotlin, Android Sample Java

It's okay, we get it! You got Stuck!
😞
Feel free to contact us on #ask-for-help on our Discord