Showing
3 changed files
with
50 additions
and
2 deletions
... | @@ -36,6 +36,8 @@ dependencies { | ... | @@ -36,6 +36,8 @@ dependencies { |
36 | implementation 'com.android.support:appcompat-v7:27.1.1' | 36 | implementation 'com.android.support:appcompat-v7:27.1.1' |
37 | implementation 'com.android.support:design:27.1.1' | 37 | implementation 'com.android.support:design:27.1.1' |
38 | 38 | ||
39 | + implementation 'com.google.firebase:firebase-analytics:17.2.0' | ||
40 | + implementation 'com.google.firebase:firebase-messaging:20.0.0' | ||
39 | 41 | ||
40 | implementation 'com.google.firebase:firebase-database:17.0.0' | 42 | implementation 'com.google.firebase:firebase-database:17.0.0' |
41 | testImplementation 'junit:junit:4.12' | 43 | testImplementation 'junit:junit:4.12' | ... | ... |
... | @@ -7,6 +7,10 @@ import androidx.appcompat.app.AppCompatActivity | ... | @@ -7,6 +7,10 @@ import androidx.appcompat.app.AppCompatActivity |
7 | import com.google.firebase.auth.FirebaseAuth | 7 | import com.google.firebase.auth.FirebaseAuth |
8 | import com.google.firebase.database.FirebaseDatabase | 8 | import com.google.firebase.database.FirebaseDatabase |
9 | import kotlinx.android.synthetic.main.activity_signup.* | 9 | import kotlinx.android.synthetic.main.activity_signup.* |
10 | +import android.util.Log | ||
11 | +import com.google.android.gms.tasks.OnCompleteListener | ||
12 | +import com.google.firebase.iid.FirebaseInstanceId | ||
13 | + | ||
10 | 14 | ||
11 | data class User( | 15 | data class User( |
12 | val u_token : String = "", | 16 | val u_token : String = "", |
... | @@ -14,7 +18,7 @@ data class User( | ... | @@ -14,7 +18,7 @@ data class User( |
14 | ) | 18 | ) |
15 | 19 | ||
16 | var cnt = 0 | 20 | var cnt = 0 |
17 | - | 21 | +var tkn="" |
18 | class SignUpActivity : AppCompatActivity() { | 22 | class SignUpActivity : AppCompatActivity() { |
19 | 23 | ||
20 | private val firebaseAuth = FirebaseAuth.getInstance() | 24 | private val firebaseAuth = FirebaseAuth.getInstance() |
... | @@ -25,10 +29,42 @@ class SignUpActivity : AppCompatActivity() { | ... | @@ -25,10 +29,42 @@ class SignUpActivity : AppCompatActivity() { |
25 | setContentView(R.layout.activity_signup) | 29 | setContentView(R.layout.activity_signup) |
26 | 30 | ||
27 | signupBtn.setOnClickListener{ | 31 | signupBtn.setOnClickListener{ |
32 | + sendToken() | ||
28 | createEmail() | 33 | createEmail() |
29 | } | 34 | } |
35 | + | ||
36 | + //pushing code start | ||
37 | + intent.extras?.let { | ||
38 | + for (key in it.keySet()) { | ||
39 | + val value = intent.extras?.get(key) | ||
40 | + Log.d(TAG, "Key: $key Value: $value") | ||
41 | + } | ||
42 | + } | ||
43 | + //pushing code end | ||
44 | + | ||
45 | + | ||
30 | } | 46 | } |
31 | 47 | ||
48 | + //pushing code start 2 | ||
49 | + private fun sendToken(){ | ||
50 | + FirebaseInstanceId.getInstance().instanceId | ||
51 | + .addOnCompleteListener(OnCompleteListener { task -> | ||
52 | + if (!task.isSuccessful) { | ||
53 | + Log.w(TAG, "getInstanceId failed", task.exception) | ||
54 | + return@OnCompleteListener | ||
55 | + } | ||
56 | + | ||
57 | + // Get new Instance ID token | ||
58 | + tkn = task.result!!.token | ||
59 | + | ||
60 | + // Log and toast | ||
61 | + val msg = getString(R.string.msg_token_fmt, tkn) | ||
62 | + Log.d(TAG, msg) | ||
63 | + Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() | ||
64 | + }) | ||
65 | + } | ||
66 | + //pushing code end 2 | ||
67 | + | ||
32 | private fun writeNewUser(u_id: String, u_token: String, Policy: String?) { | 68 | private fun writeNewUser(u_id: String, u_token: String, Policy: String?) { |
33 | val user = User(u_token, Policy!!) | 69 | val user = User(u_token, Policy!!) |
34 | user_db.child(u_id).setValue(user)/// .setValue(user) | 70 | user_db.child(u_id).setValue(user)/// .setValue(user) |
... | @@ -41,7 +77,7 @@ class SignUpActivity : AppCompatActivity() { | ... | @@ -41,7 +77,7 @@ class SignUpActivity : AppCompatActivity() { |
41 | // Sign in success, update UI with the signed-in user's information | 77 | // Sign in success, update UI with the signed-in user's information |
42 | val user = firebaseAuth?.currentUser | 78 | val user = firebaseAuth?.currentUser |
43 | Toast.makeText(this, "회원가입 완료!", Toast.LENGTH_SHORT).show() | 79 | Toast.makeText(this, "회원가입 완료!", Toast.LENGTH_SHORT).show() |
44 | - writeNewUser(user!!.uid, "따큰$cnt", "NULL$cnt") | 80 | + writeNewUser(user!!.uid, "$tkn", "NULL$cnt") |
45 | cnt ++ | 81 | cnt ++ |
46 | 82 | ||
47 | if(user!=null){ | 83 | if(user!=null){ |
... | @@ -54,4 +90,11 @@ class SignUpActivity : AppCompatActivity() { | ... | @@ -54,4 +90,11 @@ class SignUpActivity : AppCompatActivity() { |
54 | } | 90 | } |
55 | } | 91 | } |
56 | } | 92 | } |
93 | + | ||
94 | + //pushing code start 3 | ||
95 | + companion object { | ||
96 | + | ||
97 | + private const val TAG = "SignUpActivity" | ||
98 | + } | ||
99 | + //pushing code end 3 | ||
57 | } | 100 | } | ... | ... |
... | @@ -17,4 +17,7 @@ | ... | @@ -17,4 +17,7 @@ |
17 | <string name="timer">찜 목록</string> | 17 | <string name="timer">찜 목록</string> |
18 | <string name="stopwatch">내 정보</string> | 18 | <string name="stopwatch">내 정보</string> |
19 | 19 | ||
20 | + <string name="msg_token_fmt" translatable="false">InstanceID Token: %s</string> | ||
21 | + | ||
22 | + | ||
20 | </resources> | 23 | </resources> | ... | ... |
-
Please register or login to post a comment