Showing
3 changed files
with
34 additions
and
6 deletions
.gitignore
0 → 100644
1 | +wello_firebase_SDKKey.json | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
push_messaging.py
0 → 100644
1 | +from firebase_admin import messaging | ||
2 | +from firebase_admin import credentials | ||
3 | +import firebase_admin | ||
4 | + | ||
5 | +cred = credentials.Certificate('wello_firebase_SDKKey.json') | ||
6 | +default_app = firebase_admin.initialize_app(cred) | ||
7 | + | ||
8 | +def send_to_topic(): | ||
9 | + # [START send_to_topic] | ||
10 | + # The topic name can be optionally prefixed with "/topics/". | ||
11 | + topic = 'c1_1' | ||
12 | + | ||
13 | + # See documentation on defining a message payload. | ||
14 | + message = messaging.Message( | ||
15 | + title = 'wef', | ||
16 | + data={ | ||
17 | + 'score': '850', | ||
18 | + 'time': '2:45', | ||
19 | + }, | ||
20 | + topic=topic, | ||
21 | + ) | ||
22 | + | ||
23 | + # Send a message to the devices subscribed to the provided topic. | ||
24 | + response = messaging.send(message) | ||
25 | + # Response is a message ID string. | ||
26 | + | ||
27 | + print('Successfully sent message:', response) | ||
28 | + | ||
29 | +send_to_topic() |
... | @@ -81,17 +81,16 @@ class SearchActivity : AppCompatActivity() { | ... | @@ -81,17 +81,16 @@ class SearchActivity : AppCompatActivity() { |
81 | key.add(temp.toString()) | 81 | key.add(temp.toString()) |
82 | } | 82 | } |
83 | } | 83 | } |
84 | + | ||
85 | + no_search.setVisibility(View.GONE) | ||
86 | + policy_scroll_view.setVisibility(View.VISIBLE) | ||
87 | + | ||
84 | for (i in key) { | 88 | for (i in key) { |
85 | val key_query = database.orderByChild("Policy").equalTo("$i") | 89 | val key_query = database.orderByChild("Policy").equalTo("$i") |
86 | key_query.addListenerForSingleValueEvent(object : ValueEventListener { | 90 | key_query.addListenerForSingleValueEvent(object : ValueEventListener { |
87 | override fun onDataChange(dataSnapshot: DataSnapshot) { | 91 | override fun onDataChange(dataSnapshot: DataSnapshot) { |
88 | //Toast.makeText(getBaseContext(), dataSnapshot.getValue().toString(), Toast.LENGTH_SHORT).show() | 92 | //Toast.makeText(getBaseContext(), dataSnapshot.getValue().toString(), Toast.LENGTH_SHORT).show() |
89 | 93 | ||
90 | - | ||
91 | - no_search.setVisibility(View.GONE) | ||
92 | - policy_scroll_view.setVisibility(View.VISIBLE) | ||
93 | - | ||
94 | - | ||
95 | for (memoSnapshot in dataSnapshot.children){ | 94 | for (memoSnapshot in dataSnapshot.children){ |
96 | val memo = memoSnapshot.getValue(MemoItem::class.java) | 95 | val memo = memoSnapshot.getValue(MemoItem::class.java) |
97 | 96 | ||
... | @@ -113,7 +112,6 @@ class SearchActivity : AppCompatActivity() { | ... | @@ -113,7 +112,6 @@ class SearchActivity : AppCompatActivity() { |
113 | if (key.size == 0) { | 112 | if (key.size == 0) { |
114 | policy_scroll_view.setVisibility(View.GONE) | 113 | policy_scroll_view.setVisibility(View.GONE) |
115 | no_search.setVisibility(View.VISIBLE) | 114 | no_search.setVisibility(View.VISIBLE) |
116 | - | ||
117 | } | 115 | } |
118 | ////////// | 116 | ////////// |
119 | 117 | ... | ... |
-
Please register or login to post a comment