Created
February 19, 2020 08:41
-
-
Save pyeongho/a06e836e26d9dce80bec4956aa3124d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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