Kód: Vybrat vše
#!/usr/bin/python3 -B
import firebase_admin
from firebase_admin import messaging
tokdir='/work/sour/android/tmp/'
cred_obj = firebase_admin.credentials.Certificate(
#tokdir+'test-send-b2434-firebase-adminsdk-1mutn-a5223f0525.json')
tokdir+'test-send-b2434-firebase-adminsdk-1mutn-4a909a44f9.json')
firebase_admin.initialize_app(cred_obj)
# This registration token comes from the client FCM SDKs.
with open(tokdir+'linphone-instance-token.txt', 'r') as file: registration_token = file.read().strip()
# See documentation on defining a message payload.
message = messaging.Message(
notification = messaging.Notification(
title = '-title-',
body = '-body-',
),
android = messaging.AndroidConfig(
priority = 'high',
),
token = registration_token,
)
# Send a message to the device corresponding to the provided
# registration token.
response = messaging.send(message)
# Response is a message ID string.
print('Successfully sent message:', response)
Edit: vlastně asi je potřeba knihovna, už jsem zapomněl že potřeba vytvořit ten oath token, a tom bude další zmatek.
Klidně budu s tím dale pomáhat, ale bude na vás založit Firebase účet a vytvořit klíč s novim jménem apky například Linphone Odorik - cz.odorik.linphone. Bude nutné splnit podmínky s licenci GPL 3.0 pro linphone-android a liblinphone a nějakém způsobem zveřejňovat ten apk.
Notifikace fungujou trochu jinak než jsme mysleli. U nových telefonu, notifikace nemůže vzbudit apku, vzbudí se až uživatel klikne na tu notifikaci. Až se vzbudí, proběhne registrace, invite, atd. Ale v pořádku, ta samotná notifikace může obsahovat zvonění a CLIP volajícího, nemusí se čekat na registrace a invite, telefon začne zvonit ihned jak obdrži ten push.