FAST LOGIN SDK
Fast Login SDK ANDROID
1. Overview
FastLogin provides integration to Turkcell login systems. We have developed an SDK that is highly robust, secure, lightweight, configurable and very simple to embed.
You can initialize login , register, switch account flows.
The FastLogin Android SDK is compatible with Android 4.3 (API 18), Support Library 26 and above.
2. Quick Start
2.1 Adding SDK to your Project
The simplest way to integrate the SDK into your project is to use Gradle’s Dependency Management.
Adding FastLogin’s Android SDK Dependency:
- Open your project and then open your_app | build.gradle
- Add this to Module-level /app/build.gradle before dependencies:
repositories {
maven
{
url
'https://mymavenrepo.com/repo/2ZuufY6Wl43lpKiQzKvt/'
name 'FastLogin Repo'
}
}
Add the compile dependency with the latest version of the FastLogin SDK in the build.gradle file:
implementation
('com.turkcell.dssgate:dssgate-aar-beta:2.0.13')
2.2 Setting the Required Permissions
The AndroidManifest.xml should include the following permissions:
<uses-permission
android:name="android.permission.READ_PHONE_STATE" />
<uses-permission
android:name="android.permission.GET_ACCOUNTS" />
3. SDK Initialization
Initialization of the SDK is completed in two stages.
- In the first stage, the DGLoginCoordinator is created by
using Builder Pattern. While building DGLoginCoordinator, appId is
required, theme and language parameters are optional.
- In the second stage, the call to one of the main flow is
needed (e.g. call startForLogin, startForSwitchAccount, startForRegister).
Optional Parameters;
- theme: default theme of the application exists. See Section 10.
- language: default language is TR
- environment: default environment is PROD
To initialize the SDK, add the following code in your Application activity or fragment:
DGLoginCoordinator dg = new
DGLoginCoordinator.Builder().appId(your_app_id).build();
4. SDK START LOGIN
Having initialized the SDK, start login is one of the main flows to call. It takes three boolean parameters;
- disableCellLogin: if true, cellular login functionality won’t work.
- autoLoginOnly: if true, only cellular login and remember me will work
- disableAutoLogin: if true, login process is forced to user.
- dismissCloseButton: if true, close button will be disabled for all screens.
try {
dg.startForLogin(this,
disableCellLogin, autoLoginOnly, disableAutoLogin,
dismissCloseButton);
}catch (DGException e) {
//application error handling,
e.g. required appId
}
For getting result, see Section 10.
5. SDK Start Register
Having initialized the SDK, start register is one of the main flows to call. It runs without parameters;
try {
dg.startForRegister(this);
}catch (DGException e) {
//application error handling,
e.g. required appId
}
For getting result, see Section 10.
6. SDK Switch Account
Having initialized the SDK, switch account is one of the main flows to call. It runs without parameters;
try {
dg.startForSwitchAccount(this);
}catch (DGException e) {
//application error handling,
e.g. required appId
}
For getting result, see Section 10.
7. SDK START LOGIN WITH TRANSFER TOKEN
Having initialized the SDK, start login with transfer token is one of the main flows to call. It takes three boolean parameters and one string parameter;
- disableCellLogin: if true, cellular login functionality won’t work.
- autoLoginOnly: if true, only cellular login and remember me will work
- disableAutoLogin: if true, login process is forced to user.
- dismissCloseButton: if true, close button will be disabled for all screens.
- transferToken: transfer token that taken from the backend must be passed.
try {
dg.startForLoginWithTransferToken(this,
disableCellLogin, autoLoginOnly, disableAutoLogin,
dismissCloseButton, transferToken);
}catch (DGException e) {
//application error handling,
e.g. required appId
}
For getting result, see Section 10.
8. SDK WIDGET LOGIN
Having initialized the SDK, widget login is one of the main flows to call. It doesn’t take any parameters. However, it only works if there is an active rememberme login or cellular login is enabled in the relative application.
try {
dg.startForWidgetLogin(getApplicationContext());
}catch (DGException e) {
//application error handling,
e.g. required appId
}
For getting result, see Section 9.
9. SDK WIDGET RESULT
To get the result from SDK, a class which is extended from BroadcastReceiver is needed and relative action must be registered. See below example code:
IntentFilter filter = new
IntentFilter();
filter.addAction(DGLoginCoordinator.DG_WIDGET_BROADCAST_RESULT);
WidgetReceiver myReceiver = new
WidgetReceiver(this);
registerReceiver(myReceiver,
filter);
After registration, DGResult can be taken like below example code;
if
(DGLoginCoordinator.DG_WIDGET_BROADCAST_RESULT.equals(intent.getAction()))
{
DGResult dgResult =
DGLoginCoordinator.getDGResult(intent);
//dgResult has the result, take
action according to result
}
Result Type |
Description |
Action |
DGResultType.SUCCESS_LOGIN | Successful Login | You can take loginToken and continue |
DGResultType.SUCCESS_NO_LOGIN | (ONLY FOR WIDGET) Login needed in the application | For successful login to widget, there must be a logged in user. You can force user for application login |
DGResultType.ERROR_APPLICATON | There is a system error in fastlogin | You can continue Non-Login or force user to login again |
DGResultType.ERROR_SESSION_LOST | Session lost during fastlogin processes. | You can continue Non-Login or force user to login by starting fastlogin again |
10. SDK Result
To get the result from SDK, onActivityResult method must be overridden in the application’s Activity or Fragment.
Add the following code in your Application’s fragment or activity:
@Override
protected void
onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode,
resultCode, data);
if (requestCode ==
DGLoginCoordinator.DG_REQUEST_CODE) {
if (resultCode ==
Activity.RESULT_CANCELED) {
//Unexpected Error Case
}
if (resultCode ==
Activity.RESULT_OK) {
DGResult dgResult =
DGLoginCoordinator.getDGResult(data);
//dgResult has the result, take
action according to result
}
}
}
These are fastlogin result types;
Result Type |
Description |
Action |
DGResultType.SUCCESS_LOGIN | Successful Login | You can take loginToken and continue |
DGResultType.ERROR_USER_QUIT | User intentionaly quits from fastlogin | You can continue Non-Login or force user to login again by starting fastlogin again |
DGResultType.ERROR_APPLICATON | There is a system error in fastlogin | You can continue Non-Login or force user to login again |
DGResultType.ERROR_SESSION_LOST | Session lost during fastlogin processes. | You can continue Non-Login or force user to login by starting fastlogin again |
11. SDK Logout
To logout from the system, there is a static method to call. Re-initialization of DGLoginCoordinator is not needed. Add the following code in your Application:
DGLoginCoordinator.logout(this,
your_app_id);
For logout, there is no result. Having called the logout method is enough.
12. SDK Style Configuration
The configuration of the sdk can be achieved by creating DGTheme and passing DGTheme to DGLoginCoordinator. Builder pattern is used for creating the DGTheme. You can only change your background color in order to catch the same base color with your application. Furthermore changes like button color, text color etc are not allowed due to the fact that it harms the user interaction of Fastlogin
Sample code for configuring the style:
DGTheme dgTheme = new
DGTheme.Builder()
.setBackgroundColor(android.R.color.holo_green_light)
.build();
DGLoginCoordinator dg = new
DGLoginCoordinator.Builder().theme(dgTheme).appId(your_app_id).build();
13. PROGUARD CONFIGURATION
If you are using ProGuard in your project add the following lines to your configuration:
-keep class
com.turkcell.dssgate.client.** { *; }
14. FAQ
Q: Do we need to set theme in the DGLoginCoordinator?
A: No you don’t. There is a default theme in Fastlogin, if you don’t need a special theme then you can continue with the default one by not setting or just setting null for theme method in DGLoginCoordinator.
Q: Is there a test Environment for Fastlogin?
A: Yes there are 2 environments for Fastlogin which you can use. One for PROD and one for PRP . Default environment is PROD and via developer portal only PROD registration is done. If you want to work at PRP environment for special reasons please communicate with us to register your application for PRP environment. For setting the PRP environment, use the following code during initialization:
DGLoginCoordinator dg = new
DGLoginCoordinator.Builder().appId(app_id).environment(DGEnv.PRP).build();
Q: Repo url starts with “http://mymavenrepo…”, is this real repo?
A: Yes it is a real repository. Our need was a free public repo. This is the reason we are using it.
The principles regarding the use of open source codes used in the application can be accessed from the link below:
https://square.github.io/retrofit/https://square.github.io/okhttp/