Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions jetpacker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ This project is built using the standard Android Gradle build system, allowing d
- Update `sdk.dir` inside `local.properties` with your local Android SDK directory path.

2. **Firebase Setup (`google-services.json`)**:
- Register the application in your Firebase Project Console.
- Download the project's custom `google-services.json` and place it in the `android/app/` directory (overwriting the mock placeholder file).
- Register an Android app in your **Firebase Project Console** using the package name `com.example.jetpacker`.
- In the Firebase Console, navigate to **Authentication** -> **Sign-in method** and enable **Anonymous** sign-in (used for session-based communication with the booking coordinator and AI services).
- Download your project's `google-services.json` and place it in the `android/app/` directory (replacing the mock placeholder file). The Gradle `google-services` plugin automatically parses this file and configures the required resources at build time—no code changes or extra XML files are required.
- *Git Safety*: To prevent accidentally committing your personal Firebase credentials back to the repository, tell git to ignore local changes to this file:
```bash
git update-index --skip-worktree android/app/google-services.json
```

3. **Firebase App Check Debug Attestation**:
- Run the application on an emulator or a connected device.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,24 @@ class JetPackerApplication : Application() {
ComposeUiFlags.isMediaQueryIntegrationEnabled = true
super.onCreate()
FeatureFlags.initialize(this)
Firebase.initialize(context = this)
Firebase.appCheck.installAppCheckProviderFactory(
DebugAppCheckProviderFactory.getInstance(),
)
Firebase.auth.signInAnonymously()
.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("JetPackerApplication", "Anonymous auth successful")
} else {
Log.w("JetPackerApplication", "Anonymous auth failed", task.exception)
}
try {
if (Firebase.initialize(context = this) != null) {
Firebase.appCheck.installAppCheckProviderFactory(
DebugAppCheckProviderFactory.getInstance(),
)
Firebase.auth.signInAnonymously()
.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("JetPackerApplication", "Anonymous auth successful")
} else {
Log.w("JetPackerApplication", "Anonymous auth failed", task.exception)
}
}
} else {
Log.w("JetPackerApplication", "Firebase not initialized")
}
} catch (e: Exception) {
Log.w("JetPackerApplication", "Firebase initialization error", e)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If initialization fails how the app should work? Do we need to exit here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah the rest of the features will still work so no need to fully cancel. We should just make sure not to crash

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,13 @@ class BookingAssistantViewModel @Inject constructor(

private suspend fun getFirebaseAuthToken(): String {
log("getFirebaseAuthToken: getting FirebaseAuth instance")
val auth = FirebaseAuth.getInstance()
val auth = try {
FirebaseAuth.getInstance()
} catch (e: Exception) {
log("FirebaseAuth.getInstance failed: ${e.message}")
Log.e("BookingAssistant", "FirebaseAuth.getInstance failed", e)
return ""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we return an empty token here? should it return the exception?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically we choose to catch the exception here instead of at the caller site so that we can run the app even when firebase is not initialized and at least test the other features. Not the best user experience as the firebase features would not work, but that's not our demo scenario anyway.

}
var user = auth.currentUser
log("getFirebaseAuthToken: current user is ${user?.uid ?: "null"}")
if (user == null) {
Expand Down
Loading