-
Notifications
You must be signed in to change notification settings - Fork 0
oDoc Android SDK
Kasun Chinthaka Piyarathna edited this page Feb 28, 2020
·
2 revisions
- Android Studio
- Make sure that your app meets the following requirements:
- Targets API level 18 (Kitkat) or later
- Add JitPack in your root build.gradle at the end of repositories:
allprojects { repositories { … maven { url 'https://jitpack.io' } } }
- Add the dependency
'implementation 'life.odoc:odoc-android-monorepo:Tag'
-
Initialize oDoc SDK through your Application class or the main activity class.
OdocPatientSdk.init( Application Context);
-
Call OdocPatientSdk instance.
OdocPatientSdk odocPatientSdk = OdocPatientSdk.getInstance();
-
Call instance methods
odocPatientSdk.attachListener(this.callback);
This Callback can be implemented as follows.
private OdocPatientSdk.Callback<Bundle> callback = response -> { String token = response.getString(AUTH_TOKEN); /* This token can be saved in any data source for next use. For example, SharedPreferences can be used here. */ SharedPreferences.Editor editor = getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit(); editor.putString(AUTH_TOKEN, token); editor.apply(); };
Make sure to import followings in order to work with callBack
import life.odoc.patientsdk.OdocPatientSdk; import static life.odoc.patientsdk.OdocPatientSdk.Param.AUTH_TOKEN;
odocPatientSdk.setAppId(“XXX”); odocPatientSdk.setAuthToken(“XXX”); /* For signUp, you can pass an empty string to setAuthToken. Next time onwards, A valid auth token should be passed here. */ odocPatientSdk.setSdkMode(DEVELOPMENT);
Make sure to import one of Available SDK modes as following
import static life.odoc.patientsdk.OdocPatientSdk.Mode.DEVELOPMENT; import static life.odoc.patientsdk.OdocPatientSdk.Mode.PRODUCTION;
odocPatientSdk.setPhoneNumber(“71XXXXXXX”); odocPatientSdk.setFirstName(“Kasun”); odocPatientSdk.setLastName(“Chinthaka”); odocPatientSdk.setJsonData(“{}”);
-
Open oDoc app
odocPatientSdk.show();