demo transaksi
This commit is contained in:
@@ -1,30 +1,4 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'realm-android'
|
||||
|
||||
android {
|
||||
namespace "id.ontime.driver"
|
||||
signingConfigs {
|
||||
debug {
|
||||
// Use default debug keystore on this machine
|
||||
}
|
||||
}
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "id.ontime.driver"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 34
|
||||
versionCode 10
|
||||
versionName '1.1.0'
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
productFlavors {
|
||||
}
|
||||
:
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
@@ -491,8 +491,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
}
|
||||
request.setPassword(password.getText().toString());
|
||||
|
||||
// Enforce FCM token: login ONLY proceeds when we have a non-empty Firebase token.
|
||||
// 1) Try to use token that was already stored in Realm (BaseApp / MessagingService.onNewToken).
|
||||
// Best effort FCM token: use cached token first, then try fresh token.
|
||||
io.realm.Realm realm = BaseApp.getInstance(this).getRealmInstance();
|
||||
FirebaseToken storedToken = realm.where(FirebaseToken.class).findFirst();
|
||||
if (storedToken != null && storedToken.getTokenId() != null && !storedToken.getTokenId().isEmpty()) {
|
||||
@@ -501,7 +500,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2) If not yet stored, request a fresh token from FirebaseMessaging.
|
||||
// If token is still warming up, continue login without blocking user.
|
||||
try {
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(task -> {
|
||||
@@ -518,15 +517,11 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
doLoginRequest(request, emailText);
|
||||
} else {
|
||||
// Token is required: stop login and show message.
|
||||
progresshide();
|
||||
notif("Firebase token not ready, please check your network and try again.");
|
||||
doLoginRequest(request, emailText);
|
||||
}
|
||||
});
|
||||
} catch (IllegalStateException e) {
|
||||
// Firebase not initialized: block login instead of proceeding without token.
|
||||
progresshide();
|
||||
notif("Firebase is not initialized, cannot login. Please restart the app.");
|
||||
doLoginRequest(request, emailText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +534,8 @@ public class LoginActivity extends AppCompatActivity {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
LoginResponseJson body = response.body();
|
||||
if (body != null && body.getMessage().equalsIgnoreCase("found")) {
|
||||
if (body != null && body.getMessage().equalsIgnoreCase("found")
|
||||
&& body.getData() != null && !body.getData().isEmpty()) {
|
||||
User user = body.getData().get(0);
|
||||
saveUser(user);
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
@@ -549,6 +545,8 @@ public class LoginActivity extends AppCompatActivity {
|
||||
} else {
|
||||
notif(getString(R.string.phoneemailwrong));
|
||||
}
|
||||
} else {
|
||||
notif(getString(R.string.phoneemailwrong));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,9 @@ public class BaseApp extends Application {
|
||||
|
||||
// FCM v1: async token fetch and topic subscribe (reference: test app).
|
||||
try {
|
||||
FirebaseApp app = FirebaseApp.initializeApp(this);
|
||||
FirebaseApp app = FirebaseApp.getApps(this).isEmpty()
|
||||
? FirebaseApp.initializeApp(this)
|
||||
: FirebaseApp.getInstance();
|
||||
if (app != null) {
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(task -> {
|
||||
|
||||
@@ -8,7 +8,7 @@ buildscript {
|
||||
dependencies {
|
||||
// Android Gradle Plugin compatible with Gradle 8.x and JDK 21
|
||||
classpath 'com.android.tools.build:gradle:8.5.0'
|
||||
classpath 'com.google.gms:google-services:4.3.10'
|
||||
classpath 'com.google.gms:google-services:4.4.2'
|
||||
// Realm plugin variant that uses the new AGP transformer API
|
||||
classpath 'io.realm:realm-gradle-plugin:10.14.0-transformer-api'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user