def send_notification(uid,result_status,image_id): 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('SentinelProc').child(uid).child('TokenId').get() print(registration_token) t = 'Crop Health Monitoring Result' if result_status=='failed0': b = 'Satellite and device locations could not match. We hope to solve this issue as we add more satellite constellations' elif result_status=='failed1': b = 'Processed Image contains too much incomplete information. The satellite imagery could not capture your place in its previous visit.' elif result_status=='failed2': b = 'The Health Monitoring Could not receive your coordinates proerly. Please try again.' elif result_status=='send_start': t = 'On Demand Satellite Imagery' b='System has started working on your Satellite Imagery Request. You will receive an email shortly' else: b = 'The result for your field is ready. Please open the app to see it.' # 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, data={ 'image_id': image_id, 'result_status': result_status }, ) # Send a message to the device corresponding to the provided # registration token. try: response = messaging.send(message) except: print('token not found') # Response is a message ID string. print('Successfully sent message:', response) return