Skip to content

Commit

Permalink
update code flow logout and bump up version 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Arief Nur Putranto committed Oct 25, 2022
1 parent fc22c6f commit 20ee890
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 28 deletions.
16 changes: 3 additions & 13 deletions app/src/main/java/com/qiscus/dragonfly/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public void loginOrLogout(View view) {
/* Qiscus.setUser("arief92", "arief92")
.withUsername("arief92")*/

Qiscus.setUser("y@mail.com", "123456")
.withUsername("testing_y")
Qiscus.setUser("testing34", "testing34")
.withUsername("testing34")
.save()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Expand Down Expand Up @@ -269,17 +269,7 @@ public void onError(Throwable throwable) {

private void logoutUser() {
if (QiscusCore.hasSetupUser()) {
QiscusCore.logout(new QiscusCore.LogoutListener() {
@Override
public void onSuccess() {
Qiscus.clearUser();
}

@Override
public void onError(Throwable throwable) {
QiscusErrorLogger.print(throwable);
}
});
Qiscus.clearUser();
}
}

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/qiscus/dragonfly/SampleApps.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public class SampleApps extends MultiDexApplication {
public void onCreate() {
super.onCreate();

// Qiscus.setup(this, QISCUS_SDK_APP_ID);
Qiscus.setup(this, QISCUS_SDK_APP_ID);

// for test refresh token
Qiscus.setupWithCustomServer(
this, "dragongo", "https://dragongo.qiscus.com",
"ssl://realtime-stag.qiscus.com", null
);
// Qiscus.setupWithCustomServer(
// this, "dragongo", "https://dragongo.qiscus.com",
// "ssl://realtime-stag.qiscus.com", null
// );

Qiscus.getChatConfig()
.enableDebugMode(true)
Expand Down
14 changes: 8 additions & 6 deletions chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -1144,20 +1144,22 @@ private static boolean isValidToRefreshToken(QiscusAccount account) {
|| QiscusDateUtil.isPassingDateTimeSdf(expiredAt.getTime());
}

/**
* Clear all current user qiscus data, you can call this method when user logout for example.
*/
public static void logout(LogoutListener listener) {
public static void clearUser() {
if (hasSetupUser()) {
QiscusAccount account = localDataManager.getAccountInfo();
QiscusApi.getInstance().logout(account.getEmail(), account.getToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(jsonObject -> listener.onSuccess(), listener::onError);
.subscribe(jsonObject -> {
clearData();
}, throwable -> {
clearData();
});
}

}

public static void clearUser() {
private static void clearData(){
if (BuildVersionUtil.isOreoOrHigher()) {
JobScheduler jobScheduler = (JobScheduler) appInstance.getSystemService(Context.JOB_SCHEDULER_SERVICE);
if (jobScheduler != null) {
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Secondly, you need to add SDK dependencies inside your app .gradle. Then, you ne
```
dependencies {
...
implementation 'com.qiscus.sdk:chat-core:1.5.1'
implementation 'com.qiscus.sdk:chat-core:1.6.0'
}
```

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ chatVersionPatch=3

# === qiscus chat-core library version ===
chatCoreVersionMajor=1
chatCoreVersionMinor=5
chatCoreVersionPatch=1
chatCoreVersionMinor=6
chatCoreVersionPatch=0

# === qiscus default base url
BASE_URL_SERVER="https://api.qiscus.com/"
Expand All @@ -57,7 +57,7 @@ android.enableR8=true

libraryGroupId=com.qiscus.sdk
libraryArtifactId=chat-core
libraryVersion=1.5.1
libraryVersion=1.6.0

libraryGroupIdChat=com.qiscus.sdk
libraryArtifactIdChat=chat
Expand Down

0 comments on commit 20ee890

Please sign in to comment.