Skip to content

Commit

Permalink
add eventBus when success autoRefreshToken
Browse files Browse the repository at this point in the history
  • Loading branch information
Arief Nur Putranto committed Sep 18, 2024
1 parent 11eb8e4 commit 1df967f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Second, you need to add SDK dependencies inside your app .gradle. Then, you need
```
dependencies {
...
implementation 'com.qiscus.sdk:chat-core:1.8.1'
implementation 'com.qiscus.sdk:chat-core:1.8.2'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ private static void autoRefreshToken(int code, JSONObject jsonObject) throws JSO
QiscusCore.refreshToken(new QiscusCore.SetRefreshTokenListener() {
@Override
public void onSuccess(QiscusRefreshToken refreshToken) {

EventBus.getDefault().post(
new QiscusRefreshTokenEvent(
200, "Success"
)
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ public class QiscusRefreshTokenEvent {
// default code
public static final int UNAUTHORIZED = 401;
public static final int EXPIRED_TOKEN = 403;
public static final int SUCCESS_AUTO_REFRESH_TOKEN = 200;
// default message
public static String TOKEN_EXPIRED_MESSAGE = "Unauthorized. Token is expired";
public static String UNAUTHORIZED_MESSAGE = "Unauthorized";
public static String SUCCESS_AUTO_REFRESH_TOKEN_MESSAGE = "Success";

private final int code;
private final String message;
Expand All @@ -32,4 +34,9 @@ public boolean isTokenExpired() {
public boolean isUnauthorized() {
return (code == UNAUTHORIZED || code == EXPIRED_TOKEN) && message.equals(UNAUTHORIZED_MESSAGE);
}

public boolean isSuccessAutoRefreshToken() {
return code == SUCCESS_AUTO_REFRESH_TOKEN && message.equals(SUCCESS_AUTO_REFRESH_TOKEN_MESSAGE);
}

}
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.8.1'
implementation 'com.qiscus.sdk:chat-core:1.8.2'
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ chatVersionPatch=0
# === qiscus chat-core library version ===
chatCoreVersionMajor=1
chatCoreVersionMinor=8
chatCoreVersionPatch=1
chatCoreVersionPatch=2

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

libraryGroupId=com.qiscus.sdk
libraryArtifactId=chat-core
libraryVersion=1.8.1
libraryVersion=1.8.2

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

0 comments on commit 1df967f

Please sign in to comment.