def send_error_noti(uid): import firebase_admin from firebase_admin import credentials from firebase_admin import db from firebase_admin import messaging # Fetch the service account key JSON file contents cred = credentials.Certificate('servicekey.json') # Initialize the app with a service account, granting admin privileges registration_token = db.reference('AllTokens').child(uid).get() print(registration_token) t = 'Too much Cloud Cover Above Your Field' b = 'During the last visit of the satellite over your field, there was significant cloud cover, hence satellite monitoring results could not be generated. We will attempt to process images again when the satellite crosses your field location once more. Since the imagery was not captured properly by the satellite this time, this date will not be included in your package' # See documentation on defining a message payload. message = messaging.Message( android=messaging.AndroidConfig( priority='normal', notification=messaging.AndroidNotification( title=t, body=b, icon='ic_notification', color='#006666', sound='notification_sound', tag = 'satelliteprocessingresult' ), ), token=registration_token ) # Send a message to the device corresponding to the provided # registration token. try: response = messaging.send(message) # Response is a message ID string. print('Successfully sent message:', response) return except: print('Token Not Found') return