Skip to content

Instantly share code, notes, and snippets.

@pyeongho
Created February 19, 2020 08:41
Show Gist options
  • Save pyeongho/a06e836e26d9dce80bec4956aa3124d0 to your computer and use it in GitHub Desktop.
Save pyeongho/a06e836e26d9dce80bec4956aa3124d0 to your computer and use it in GitHub Desktop.
FirebaseApp.initializeApp(this)
private fun addFireTypeData(add :Boolean , adiscopePayload: String, adid: String){
try {
val auth = FirebaseAuth.getInstance();
if (adiscopePayload.isNotEmpty()) {
auth.signInWithEmailAndPassword("******@******.in", "******")
.addOnCompleteListener { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
val db = FirebaseFirestore.getInstance()
val user = hashMapOf(
"adiscopePayload" to adiscopePayload,
"adid" to adid,
"hasSponsorship" to add
)
db.collection("allData")
.add(user)
.addOnSuccessListener { documentReference ->
log.d("DocumentSnapshot added with ID: ${documentReference.id}")
auth.signOut()
}
.addOnFailureListener { e ->
auth.signOut()
log.e("Error adding document $e")
}
} else {
log.l()
}
}
.addOnFailureListener { e ->
log.e(e.message)
}
}
}catch (e:Exception){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment