File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import firebase_admin
2+ from firebase_admin import credentials
3+ from firebase_admin import messaging
4+
5+ cred_path = "coupang-b83fe-firebase-adminsdk-7mcpg-0967b8e8cd.json"
6+ cred = credentials .Certificate (cred_path )
7+ default_app = firebase_admin .initialize_app (cred )
8+
9+ registration_tokens = ['fMtg9MuSTBi80CWFjH3ShU:APA91bFwQlHt_Ratbt2CwjBi4coEFFj3IoY5xGZbcU_mBANs-cH4001Dg1H_jadQumV3bixqlAClmuTevP6ZvvtpZqXLO79x6Jw4edz7pY9DiK1u9BWenlUz196vTcZsksypJpA-QumC' ,
10+ 'f1jcyan9RLWLKa77ZFvVaz:APA91bGTmueB6iQFyKkaWJqI9xnIbMZ_qp2S0tR7hkMvERE4VCyag5tZPgybeRTnb3R7ai6pj8zDXLxHyUu9qzrQWSmoQVjEcKunvSvs1CkGXU2dkGm7SEL_PtX2XByJYtlM0k8MyoFW' ]
11+
12+ message = messaging .MulticastMessage (
13+ notification = messaging .Notification (
14+ title = 'test' ,
15+ body = 'python push test' ,
16+ image = 'https://icnu.kr/coupang/logo.png'
17+ ),
18+ data = {
19+ 'title' :'test' ,
20+ 'message' :'python fcm test' ,
21+ 'mode' :'test' ,
22+ 'data' :'12345'
23+ },
24+ tokens = registration_tokens ,
25+ )
26+ response = messaging .send_multicast (message )
27+ print ('Successfully sent message:' , response )
Original file line number Diff line number Diff line change 1+ # https://github.com/firebase/firebase-admin-python/blob/master/snippets/messaging/cloud_messaging.py
2+
3+ import firebase_admin
4+ from firebase_admin import credentials
5+ from firebase_admin import messaging
6+
7+ cred_path = "coupang-b83fe-firebase-adminsdk-7mcpg-0967b8e8cd.json"
8+ cred = credentials .Certificate (cred_path )
9+ default_app = firebase_admin .initialize_app (cred )
10+
11+ topic = 'testTopic'
12+
13+ message = messaging .Message (
14+ notification = messaging .Notification (
15+ title = 'test' ,
16+ body = 'python push test' ,
17+ image = 'https://icnu.kr/coupang/logo.png'
18+ ),
19+ data = {
20+ 'title' :'test' ,
21+ 'message' :'python fcm test' ,
22+ 'mode' :'test' ,
23+ 'data' :'12345'
24+ },
25+ topic = topic ,
26+ )
27+ response = messaging .send (message )
28+ print ('Successfully sent message:' , response )
Original file line number Diff line number Diff line change 1+ # https://github.com/firebase/firebase-admin-python/blob/master/snippets/messaging/cloud_messaging.py
2+
3+ import firebase_admin
4+ from firebase_admin import credentials
5+ from firebase_admin import messaging
6+
7+ cred_path = "coupang-b83fe-firebase-adminsdk-7mcpg-0967b8e8cd.json"
8+ cred = credentials .Certificate (cred_path )
9+ default_app = firebase_admin .initialize_app (cred )
10+
11+ registration_token = 'fMtg9MuSTBi80CWFjH3ShU:APA91bFwQlHt_Ratbt2CwjBi4coEFFj3IoY5xGZbcU_mBANs-cH4001Dg1H_jadQumV3bixqlAClmuTevP6ZvvtpZqXLO79x6Jw4edz7pY9DiK1u9BWenlUz196vTcZsksypJpA-QumC'
12+ # registration_token = 'f1jcyan9RLWLKa77ZFvVaz:APA91bGTmueB6iQFyKkaWJqI9xnIbMZ_qp2S0tR7hkMvERE4VCyag5tZPgybeRTnb3R7ai6pj8zDXLxHyUu9qzrQWSmoQVjEcKunvSvs1CkGXU2dkGm7SEL_PtX2XByJYtlM0k8MyoFW'
13+
14+ message = messaging .Message (
15+ notification = messaging .Notification (
16+ title = 'test' ,
17+ body = 'python push test' ,
18+ image = 'https://icnu.kr/coupang/logo.png'
19+ ),
20+ data = {
21+ 'title' :'test' ,
22+ 'message' :'python fcm test' ,
23+ 'mode' :'test' ,
24+ 'data' :'12345'
25+ },
26+ token = registration_token ,
27+ )
28+ response = messaging .send (message )
29+ print ('Successfully sent message:' , response )
You can’t perform that action at this time.
0 commit comments