Skip to content
Merged
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
2 changes: 1 addition & 1 deletion admob/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MainActivity :
param(FirebaseAnalytics.Param.ITEM_LIST_NAME, "Related products")
param(
FirebaseAnalytics.Param.ITEMS,
arrayOf(itemJeggingsWithIndex, itemBootsWithIndex, itemSocksWithIndex)
arrayOf(itemJeggingsWithIndex, itemBootsWithIndex, itemSocksWithIndex),
)
}
// [END view_item_list]
Expand Down
2 changes: 1 addition & 1 deletion analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21"
}
}

Expand Down
2 changes: 1 addition & 1 deletion appcheck/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation 'com.google.firebase:firebase-appcheck:16.1.2'
implementation 'com.google.firebase:firebase-appcheck-ktx:16.1.2'
implementation 'com.google.firebase:firebase-appcheck-debug:16.1.2'
implementation 'com.google.firebase:firebase-appcheck-playintegrity:16.1.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import retrofit2.Retrofit
import retrofit2.http.GET
import retrofit2.http.Header


// [START appcheck_custom_backend]
class ApiWithAppCheckExample {
interface YourExampleBackendService {
@GET("yourExampleEndpoint")
fun exampleData(
@Header("X-Firebase-AppCheck") appCheckToken: String
@Header("X-Firebase-AppCheck") appCheckToken: String,
): Call<List<String>>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import com.google.firebase.appcheck.AppCheckProvider
import com.google.firebase.appcheck.AppCheckProviderFactory
import com.google.firebase.appcheck.AppCheckToken
import com.google.firebase.appcheck.FirebaseAppCheck
import com.google.firebase.ktx.Firebase
import com.google.firebase.ktx.initialize

class CustomProvider {
// [START appcheck_custom_provider]
class YourCustomAppCheckToken(
private val token: String,
private val expiration: Long
private val expiration: Long,
) : AppCheckToken() {
override fun getToken(): String = token
override fun getExpireTimeMillis(): Long = expiration
Expand Down Expand Up @@ -49,11 +51,11 @@ class CustomProvider {

private fun init(context: Context) {
// [START appcheck_initialize_custom_provider]
FirebaseApp.initializeApp(/*context=*/ context)
Firebase.initialize(context)
val firebaseAppCheck = FirebaseAppCheck.getInstance()
firebaseAppCheck.installAppCheckProviderFactory(
YourCustomAppCheckProviderFactory()
YourCustomAppCheckProviderFactory(),
)
// [END appcheck_initialize_custom_provider]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.google.firebase.example.appcheck.kotlin

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.FirebaseApp
import com.google.firebase.appcheck.FirebaseAppCheck
import com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory
import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory
import com.google.firebase.example.appcheck.R

import com.google.firebase.ktx.Firebase
import com.google.firebase.ktx.initialize

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -17,21 +17,21 @@ class MainActivity : AppCompatActivity() {

private fun init() {
// [START appcheck_initialize]
FirebaseApp.initializeApp(/*context=*/this)
Firebase.initialize(context = this)
val firebaseAppCheck = FirebaseAppCheck.getInstance()
firebaseAppCheck.installAppCheckProviderFactory(
PlayIntegrityAppCheckProviderFactory.getInstance()
PlayIntegrityAppCheckProviderFactory.getInstance(),
)
// [END appcheck_initialize]
}

private fun initDebug() {
// [START appcheck_initialize_debug]
FirebaseApp.initializeApp(/*context=*/this)
Firebase.initialize(context = this)
val firebaseAppCheck = FirebaseAppCheck.getInstance()
firebaseAppCheck.installAppCheckProviderFactory(
DebugAppCheckProviderFactory.getInstance()
DebugAppCheckProviderFactory.getInstance(),
)
// [END appcheck_initialize_debug]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ class AnonymousAuthActivity : Activity() {
private fun signInAnonymously() {
// [START signin_anonymously]
auth.signInAnonymously()
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInAnonymously:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInAnonymously:failure", task.exception)
Toast.makeText(baseContext, "Authentication failed.",
Toast.LENGTH_SHORT).show()
updateUI(null)
}
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInAnonymously:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInAnonymously:failure", task.exception)
Toast.makeText(
baseContext,
"Authentication failed.",
Toast.LENGTH_SHORT,
).show()
updateUI(null)
}
}
// [END signin_anonymously]
}

Expand All @@ -61,23 +64,25 @@ class AnonymousAuthActivity : Activity() {
val credential = EmailAuthProvider.getCredential("", "")
// [START link_credential]
auth.currentUser!!.linkWithCredential(credential)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
Log.d(TAG, "linkWithCredential:success")
val user = task.result?.user
updateUI(user)
} else {
Log.w(TAG, "linkWithCredential:failure", task.exception)
Toast.makeText(baseContext, "Authentication failed.",
Toast.LENGTH_SHORT).show()
updateUI(null)
}
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
Log.d(TAG, "linkWithCredential:success")
val user = task.result?.user
updateUI(user)
} else {
Log.w(TAG, "linkWithCredential:failure", task.exception)
Toast.makeText(
baseContext,
"Authentication failed.",
Toast.LENGTH_SHORT,
).show()
updateUI(null)
}
}
// [END link_credential]
}

private fun updateUI(user: FirebaseUser?) {

}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,28 @@ class CustomAuthActivity : Activity() {
// [START sign_in_custom]
customToken?.let {
auth.signInWithCustomToken(it)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCustomToken:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithCustomToken:failure", task.exception)
Toast.makeText(baseContext, "Authentication failed.",
Toast.LENGTH_SHORT).show()
updateUI(null)
}
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCustomToken:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithCustomToken:failure", task.exception)
Toast.makeText(
baseContext,
"Authentication failed.",
Toast.LENGTH_SHORT,
).show()
updateUI(null)
}
}
}
// [END sign_in_custom]
}

private fun updateUI(user: FirebaseUser?) {

}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class EmailPasswordActivity : Activity() {
private lateinit var auth: FirebaseAuth
// [END declare_auth]


public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -30,7 +29,7 @@ class EmailPasswordActivity : Activity() {
super.onStart()
// Check if user is signed in (non-null) and update UI accordingly.
val currentUser = auth.currentUser
if(currentUser != null){
if (currentUser != null) {
reload()
}
}
Expand All @@ -39,59 +38,63 @@ class EmailPasswordActivity : Activity() {
private fun createAccount(email: String, password: String) {
// [START create_user_with_email]
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "createUserWithEmail:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "createUserWithEmail:failure", task.exception)
Toast.makeText(baseContext, "Authentication failed.",
Toast.LENGTH_SHORT).show()
updateUI(null)
}
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "createUserWithEmail:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "createUserWithEmail:failure", task.exception)
Toast.makeText(
baseContext,
"Authentication failed.",
Toast.LENGTH_SHORT,
).show()
updateUI(null)
}
}
// [END create_user_with_email]
}

private fun signIn(email: String, password: String) {
// [START sign_in_with_email]
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithEmail:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithEmail:failure", task.exception)
Toast.makeText(baseContext, "Authentication failed.",
Toast.LENGTH_SHORT).show()
updateUI(null)
}
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithEmail:success")
val user = auth.currentUser
updateUI(user)
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithEmail:failure", task.exception)
Toast.makeText(
baseContext,
"Authentication failed.",
Toast.LENGTH_SHORT,
).show()
updateUI(null)
}
}
// [END sign_in_with_email]
}

private fun sendEmailVerification() {
// [START send_email_verification]
val user = auth.currentUser!!
user.sendEmailVerification()
.addOnCompleteListener(this) { task ->
// Email Verification sent
}
.addOnCompleteListener(this) { task ->
// Email Verification sent
}
// [END send_email_verification]
}

private fun updateUI(user: FirebaseUser?) {

}

private fun reload() {

}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ class EmulatorSuite {
Firebase.auth.useEmulator("10.0.2.2", 9099)
// [END auth_emulator_connect]
}

}
}
Loading