import requests url = "https://fcm.googleapis.com/fcm/send" def send_notification(user_obj,title,body): try: if 'token_id' in user_obj: payload={ "to" : user_obj['token_id'], "collapse_key" : "type_a", "notification" : { "body" : body, "title": title } } headers = { 'Content-Type': 'application/json', 'Authorization': 'key= AIzaSyDPCiE4_KysqE2necy9dokclU9ocINEsSw' } response = requests.request("POST", url, headers=headers, data=payload) except Exception as err: print(err)