コード例 #1
0
def send_student_notification(request):
    id = request.POST.get("id")
    message = request.POST.get("message")
    student = Students.objects.get(admin=id)
    token = student.fcm_token
    url = "https://fcm.googleapis.com/fcm/send"
    body = {
        "notification": {
            "title":
            "Student Management System",
            "body":
            message,
            "click_action":
            "https://studentmanagementsystem22.herokuapp.com/student_all_notification",
            "icon":
            "http://studentmanagementsystem22.herokuapp.com/static/dist/img/user2-160x160.jpg"
        },
        "to": token
    }
    headers = {
        "Content-Type":
        "application/json",
        "Authorization":
        "key=AAAA8jHrBqI:APA91bFFHtJXpd6HkmhHFAhr2WTO0A3_c1JWPK1Bv5FeJo1mmZ32Ck9chrfixaFEiPB0RfP0xuUUwbeRUiiFBAI5i3GYo-VrlyIxaM-pAD7NteXDfzCYxd6g944M-66MnIWnMx0hHLwB"
    }
    data = request.post(url, data=json.dumps(body), headers=headers)
    notification = NotificationStudent(student_id=student, message=message)
    notification.save()
    print(data.text)
    return HttpResponse("True")
コード例 #2
0
def send_student_notification(request):
    id = request.POST.get("id")
    message = request.POST.get("message")
    student = Students.objects.get(admin=id)
    token = student.fcm_token
    url = "https://fcm.googleapis.com/fcm/send"
    body = {
        "notification": {
            "title":
            "Student Management System",
            "body":
            message,
            "click_action":
            "https://studentmanagementsystem22.herokuapp.com/student_all_notification",
            "icon":
            "http://studentmanagementsystem22.herokuapp.com/static/dist/img/user2-160x160.jpg"
        },
        "to": token
    }
    headers = {
        "Content-Type": "application/json",
        "Authorization": "key=SERVER_KEY_HERE"
    }
    data = requests.post(url, data=json.dumps(body), headers=headers)
    notification = NotificationStudent(student_id=student, message=message)
    notification.save()
    print(data.text)
    return HttpResponse("True")
コード例 #3
0
def send_student_notification(request):
    id = request.POST.get("id")
    message = request.POST.get("message")
    student = Students.objects.get(admin=id)
    token = student.fcm_token
    url = "https://fcm.googleapis.com/fcm/send"
    body = {
        "notification": {
            "title":
            "Student Management System",
            "body":
            message,
            "click_action":
            "https://studentmanagementsystem24.herokuapp.com/student_all_notification",
            "icon":
            "https://studentmanagementsystem24.herokuapp.com/static/dist/img/user2-160x160.jpg"
        },
        "to": token
    }
    headers = {
        "Content-Type":
        "application/json",
        "Authorization":
        "key=AAAAyJjPPkk:APA91bEhqTkVSSlKmxETU4_6tGUe4a_czCFE5xZ8t1D3p_SaoZ8KQGSCZhiXVinmv6x01biCG41J4XrDj7Zt_3XqdkLpLyS_ZLvq_Y-s8M-BQIzGLG174EfFR-OVPFfOVLHML5jF5nbY"
    }
    data = requests.post(url, data=json.dumps(body), headers=headers)
    notification = NotificationStudent(student_id=student, message=message)
    notification.save()
    print(data.text)
    return HttpResponse("True")
コード例 #4
0
ファイル: HodViews.py プロジェクト: Umairramaay/SMS
def send_student_notification(request):
    id = request.POST.get("id")
    message = request.POST.get("message")
    student = Students.objects.get(admin=id)
    token = student.fcm_token
    url = "https://fcm.googleapis.com/fcm/send"
    body = {
        "notification": {
            "title":
            "Student Management System",
            "body":
            message,
            "click_action":
            "http://studentms1.herokuapp.com/student_all_notification",
            "icon":
            "http://studentms1.herokuapp.com/static/dist/img/user2-160x160.jpg"
        },
        "to": token
    }
    headers = {
        "Content-Type":
        "application/json",
        "Authorization":
        "key=AAAACKLjmu4:APA91bHu13IFMBTDwrcgxW-jkqocLqRb4oDros4jBdy15iPSoNVkBvB5bRADi3CsysLPaEY1oBvwSuG5LNNsIyOs-PXdHY1OUwl95eAn-_lhqo9ETRqXr4CKqIDgsuFSMXEC_0SrKIHa"
    }
    data = requests.post(url, data=json.dumps(body), headers=headers)
    notification = NotificationStudent(student_id=student, message=message)
    notification.save()
    print(data.text)
    return HttpResponse("True")
コード例 #5
0
def send_student_notification(request):
    id = request.POST.get("id")
    message = request.POST.get("message")
    student = Students.objects.get(admin=id)
    token = student.fcm_token
    url = "https://fcm.googleapis.com/fcm/send"
    body = {
        "notification": {
            "title": "Student Management System",
            "body": message,
            "click_action": "https://mystudentmanagementsys.herokuapp.com/student_all_notification",
            "icon": "https://mystudentmanagementsys.herokuapp.com/static/dist/img/avatar04.png"
        },
        "to": token
    }
    headers = {"Content-Type": "application/json",
               "Authorization": "key=AAAA8EWBDx0:APA91bHvbcLMl_Lp5ShEXssl-BfhZkA1ekFPNxH6c8xdTqwNR_w4qE2JJOiM2FYJtKUoaPXvbDKRN18GA3qYJudhlYU5p3lzRENOTDJ5Z_x-igixDfMwVoQd5_UnFjU2vnNrHDqP5Vb2"}
    data = requests.post(url, data=json.dumps(body), headers=headers)
    notification = NotificationStudent(student_id=student, message=message)
    notification.save()
    print(data.text)
    return HttpResponse("True")