def send_expired_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 = 'Subscription Expired' b = 'Subscription Package for one of your Satellite Monitored Field has expired. Go to My Fields on Farmonaut and Click on Renew Button to renew your subscription and keep receiving satellite results.' 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