-
Notifications
You must be signed in to change notification settings - Fork 403
/
MainActivity.kt
54 lines (49 loc) · 1.86 KB
/
MainActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.google.samples.snippet.kotlin
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.installations.FirebaseInstallations
import com.google.samples.snippet.R
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
logInstallationAuthToken()
logInstallationID()
}
private fun logInstallationAuthToken() {
// [START get_installation_token]
val forceRefresh = true
FirebaseInstallations.getInstance().getToken(forceRefresh)
.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("Installations", "Installation auth token: " + task.result?.token)
} else {
Log.e("Installations", "Unable to get Installation auth token")
}
}
// [END get_installation_token]
}
private fun logInstallationID() {
// [START get_installation_id]
FirebaseInstallations.getInstance().id.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("Installations", "Installation ID: " + task.result)
} else {
Log.e("Installations", "Unable to get Installation ID")
}
}
// [END get_installation_id]
}
private fun deleteInstallation() {
// [START delete_installation]
FirebaseInstallations.getInstance().delete().addOnCompleteListener { task ->
if (task.isComplete) {
Log.d("Installations", "Installation deleted")
} else {
Log.e("Installations", "Unable to delete Installation")
}
}
// [END delete_installation]
}
}