from pyfcm import FCMNotification

push_service = FCMNotification(
    api_key=
    "AAAA2nQVSHY:APA91bHtvk7-KIs5tNzTSL0nM6oiVflIDScUEii68sToMmbMzItnn9YGK-BWCUTN-AzmwgdYvJObeGXXhD4qEQfJ5CkKFDJ6vcQhDuo_j6Fd8EdrcxLAS5mj6agxQw5gOAqZ4Kknja0c"
)

# OR initialize with proxies

proxy_dict = {
    "http": "http://127.0.0.1:8899",
    "https": "http://127.0.0.1:8899",
}
push_service = FCMNotification(
    api_key=
    "AAAA2nQVSHY:APA91bHtvk7-KIs5tNzTSL0nM6oiVflIDScUEii68sToMmbMzItnn9YGK-BWCUTN-AzmwgdYvJObeGXXhD4qEQfJ5CkKFDJ6vcQhDuo_j6Fd8EdrcxLAS5mj6agxQw5gOAqZ4Kknja0c",
    proxy_dict=proxy_dict)

# Your api-key can be gotten from:  https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging

registration_id = "cqXjukfFN2w:APA91bEKWYkk22XlZeeioYAhWIViljfVJcF31wlDxnOPOxAy1hSVOKAe2odC9t9x6MH02pUwGnKYcIN990khnHclFzblGbAcB0Qw7v9zAZEglfAyxP6MXedrrkEL-dXuVY-zHHhVUmFp"
message_title = "淹水警報!"
message_body = "高雄地區正在淹水 請盡速撤離"
result = push_service.notify_single_device(registration_id=registration_id,
                                           message_title=message_title,
                                           message_body=message_body)

print(result)

# Send to multiple devices by passing a list of ids.
# registration_ids = ["<device registration_id 1>", "<device registration_id 2>", ...]
Beispiel #2
0
from pyfcm import FCMNotification

# Api_key is fixed value based on the firebase.
push_service = FCMNotification(
    api_key=
    "AAAANwyTgsY:APA91bFTQwDKyQcozCiu9DJkmk8bZ2dZgQ9dZqxAyk5vTvYiFHjBR0AVkHGsAuCsUHNG8eCL1dqPwcRVgQv1NwtAVFn_Sku4TVTkcHA9leq0fMEbGHeFxEopSpbJKlIUEWAi25NH4nt0"
)

# Open "logcat.txt" to get registration_id.
# FCM Log has been written on first line of "logcat.txt".
# So, we use lines[0] to get it.
f = open("D:\\logcat.txt", 'r')
# If above line returns error:
# UnicodeDecodeError: 'cp949' codec can't decode byte 0xff in position 0: illegal multibyte sequence
# use this:
# f = open("D:\\logcat.txt", 'r', encoding='utf-16')
# it's because 'utf-16' can decode '0xff'
lines = f.readlines()
print(lines[0])
f.close()

# Find an index where string "Token" starts.
index = lines[0].find("Token")
print(index)

# Because lines[1] looks like "~~ FCM Token: ~~",
# we add 7 to index and read line to the end.
# (After "T", there are 7 characters "o k e n : ")
# Then, get rid of line feed '\n'.
registration_id = lines[0][index + 7:].rstrip('\n')
print(registration_id)
Beispiel #3
0
from flask import Flask, jsonify
from flask_cors import CORS
from flask import abort
from flask import make_response
from flask import request
from pyfcm import FCMNotification
import numpy as np
import pandas as pd
from sklearn.cluster import KMeans

import time
import sys
import mysql.connector

push_service = FCMNotification(api_key="AAAAd_quocY:APA91bH4wZXhrSJQ3KCRqvmmVc39agsuNo0qq4lT2HwDb9Eq4Guo-5yspMnwcWOrtkjiY9tankvx5gTcYjktldd82QSYoIp5HezvYeePLOhOFPi9oWHE4SNl564oO2xlPdDxaHs6mqEP")

app = Flask(__name__)
CORS(app)

###################################    INTEGRAÇÃO COM O K-MEANS        ###################################

predictionCount = 0

def prediction(col):
	dataset = pd.read_csv('dataset_normalized_acceleration.csv')
	
	resultado = []
	dictionary = {}

	placeID = 1
	(cr, cnx) = openConnection()
Beispiel #4
0
from pyfcm import FCMNotification

api_key = "AAAAswJN4pY:APA91bHzp0kI8gBgm8sgUtxrc6aISk3e8-PTH5y5I-Dg-Pa9KLRfcl6Rl4UxC0ajS-goV46eD7qGuVvJrwA67kLEk20UT0864aalTEjOGsGVIz9zhJppRxIFU3MHGAnlUy4KXxhSWicX"

push_service = FCMNotification(api_key=api_key)

# OR initialize with proxies

proxy_dict = {
    "http": "http://127.0.0.1",
    "https": "http://127.0.0.1",
}
push_service = FCMNotification(api_key=api_key, proxy_dict=proxy_dict)

# Your api-key can be gotten from:  https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging

registration_id = "eCcwICGFLyM:APA91bEC-XPwUMGr3B5Ka8nczLqXL39D26kVAuSY8OElK03jgVbquoiFczrytJBHCnjjGihYR7nsHX8jJggnZ7I8tmixI1PP8yukKzj5fS7WIAHPRxZOj6lWGyOhdzv7X8SyYlKijkXd"
message_title = "Uber update"
message_body = "Hi john, your customized news for today is ready"
result = push_service.notify_single_device(registration_id=registration_id,
                                           message_title=message_title,
                                           message_body=message_body)

print(result)

# Send to multiple devices by passing a list of ids.
registration_ids = [
    "<device registration_id 1>", "<device registration_id 2>", ...
]
message_title = "Uber update"
message_body = "Hope you're having fun this weekend, don't forget to check today's news"
Beispiel #5
0
from pyfcm import FCMNotification

fcm = FCMNotification(
    api_key=
    'AAAAyTAfM2Y:APA91bHhDWYab_8mLYaPWiDl28160C8st3uxWMjt_x3OvFLJgZYqdcUdQnrmBw_63KdHy4h3NtaZulyTKLtC_Rqrjw-reRSKosCkOkWH7l6gw_2Q7MOuZJv6malt_cyU8vfSOBMSHRkl'
)
Beispiel #6
0
def fcm_send_bulk_data_messages(api_key,
                                registration_ids=None,
                                condition=None,
                                collapse_key=None,
                                delay_while_idle=False,
                                time_to_live=None,
                                restricted_package_name=None,
                                low_priority=False,
                                dry_run=False,
                                data_message=None,
                                content_available=None,
                                timeout=5,
                                extra_notification_kwargs=None,
                                json_encoder=None):
    """
    Arguments correspond to those from pyfcm/fcm.py.

    Sends push message to multiple devices,
    can send to over 1000 devices

    Args:
        api_key
        registration_ids (list): FCM device registration IDs.
        data_message (dict): Data message payload to send alone or with the notification message

    Keyword Args:
        collapse_key (str, optional): Identifier for a group of messages
            that can be collapsed so that only the last message gets sent
            when delivery can be resumed. Defaults to ``None``.
        delay_while_idle (bool, optional): If ``True`` indicates that the
            message should not be sent until the device becomes active.
        time_to_live (int, optional): How long (in seconds) the message
            should be kept in FCM storage if the device is offline. The
            maximum time to live supported is 4 weeks. Defaults to ``None``
            which uses the FCM default of 4 weeks.
        low_priority (boolean, optional): Whether to send notification with
            the low priority flag. Defaults to ``False``.
        restricted_package_name (str, optional): Package name of the
            application where the registration IDs must match in order to
            receive the message. Defaults to ``None``.
        dry_run (bool, optional): If ``True`` no message will be sent but
            request will be tested.
    Returns:
        :tuple:`multicast_id(long), success(int), failure(int), canonical_ids(int), results(list)`:
        Response from FCM server.

    Raises:
        AuthenticationError: If :attr:`api_key` is not set or provided or there is an error authenticating the sender.
        FCMServerError: Internal server error or timeout error on Firebase cloud messaging server
        InvalidDataError: Invalid data provided
        InternalPackageError: JSON parsing error, mostly from changes in the response of FCM, create a new github issue to resolve it.
    """
    push_service = FCMNotification(
        api_key=SETTINGS.get("FCM_SERVER_KEY") if api_key is None else api_key,
        json_encoder=json_encoder,
    )
    return push_service.multiple_devices_data_message(
        registration_ids=registration_ids,
        condition=condition,
        collapse_key=collapse_key,
        delay_while_idle=delay_while_idle,
        time_to_live=time_to_live,
        restricted_package_name=restricted_package_name,
        low_priority=low_priority,
        dry_run=dry_run,
        data_message=data_message,
        content_available=content_available,
        timeout=timeout,
        extra_notification_kwargs=extra_notification_kwargs,
    )
Beispiel #7
0
def fcm_send_topic_message(
        api_key=None,
        topic_name=None,
        message_body=None,
        message_title=None,
        message_icon=None,
        sound=None,
        condition=None,
        collapse_key=None,
        delay_while_idle=False,
        time_to_live=None,
        restricted_package_name=None,
        low_priority=False,
        dry_run=False,
        data_message=None,
        click_action=None,
        badge=None,
        color=None,
        tag=None,
        body_loc_key=None,
        body_loc_args=None,
        title_loc_key=None,
        title_loc_args=None,
        content_available=None,
        timeout=5,
        extra_notification_kwargs=None,
        extra_kwargs={}):

    if api_key is None:
        api_key = FCM_SERVER_KEY
        push_service = FCMNotification(
            api_key=api_key)

    result = push_service.notify_topic_subscribers(
        topic_name=topic_name,
        message_body=message_body,
        message_title=message_title,
        message_icon=message_icon,
        sound=sound,
        condition=condition,
        collapse_key=collapse_key,
        delay_while_idle=delay_while_idle,
        time_to_live=time_to_live,
        restricted_package_name=restricted_package_name,
        low_priority=low_priority,
        dry_run=dry_run,
        data_message=data_message,
        click_action=click_action,
        badge=badge,
        color=color,
        tag=tag,
        body_loc_key=body_loc_key,
        body_loc_args=body_loc_args,
        title_loc_key=title_loc_key,
        title_loc_args=title_loc_args,
        content_available=content_available,
        timeout=timeout,
        extra_kwargs=extra_kwargs,
        extra_notification_kwargs=extra_notification_kwargs,
    )

    return result
Beispiel #8
0
from selenium import webdriver
from bs4 import BeautifulSoup
from pyfcm import FCMNotification
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
import pymysql
import privateInfo
push_service = FCMNotification(api_key=privateInfo.serverKey)

getSQL = "SELECT %s FROM %s %s;"  # 실행 할 쿼리문 입력
setSQL = "UPDATE subjects SET grade = '%s' %s;"
insertSQL = "INSERT INTO subjects VALUES ('%s','%s','%s');"

optionsa = webdriver.ChromeOptions()
optionsa.add_argument('headless')
optionsa.add_argument('window-size=1920x1080')
optionsa.add_argument(
    "disable-gpu")  #gpu 관련 에러가 나는경우 추가할 옵션. gpu를 이용해 js렌더링을 가속하는 옵션을 꺼줌

driver = webdriver.Chrome(privateInfo.chromeDriverPath, options=optionsa)
subjectIncluder = "mainframe_childframe_form_dvmain_dvsub_TabMainFrame_GradNowShtmGradeInq_dvFrame_gdGradeList_bodyGridBandContainerElement"
driver.get('https://kupis.konkuk.ac.kr/NxKonkuk/KUPIS/index.html')
wait = WebDriverWait(driver, 20)
while True:
    table = pymysql.connect(host=privateInfo.host,
                            port=privateInfo.port,
                            user=privateInfo.user,
                            password=privateInfo.password,
                            db=privateInfo.db)
Beispiel #9
0
    feedback_obj = get_json_by_response(env)
    users = feedback_obj['users']
    events = feedback_obj['events']

    print('EVENTS', events)
    print('USERS', users)

    # TODO: check
    if sql.post_feedback(user_obj['id'], events) or sql.post_top(user_obj['id'], date, users):
        return http.ok(env['HTTP_HOST'])
    else:
        return http.not_allowed()


from pyfcm import FCMNotification
push_service = FCMNotification(api_key="AAAAbDg5f5A:APA91bH9Z_jFxSGbhrxD0LC4SXCGKYlMj16Nz5bBIUqTITZkvtZ_2UsS8VqDuCPqXFxJidvbH5BRxSFsiQJMF2mBYbdpjMbwMY3QndOFUe2mjaoCVZGkZWjUp9LXnFXFdt6BfAflTPz6")


def post_notification(env: TEnvironment, query: TQuery, cookie: TCookie) -> TResponse:
    """ Sing in current user to pushup notifications

    Args:
        env: HTTP request environment
        query: url query parameters
        cookie: http cookie parameters (may be empty)

    Returns:
        Response - result of request
        None; Only http answer
    """
 def __init__(self):
     self.push_service = FCMNotification(api_key=self.m_api_key)
     if (self.push_service == None):
         self.__init__()
Beispiel #11
0
    def dispatch(self, **kw):
        error = {"Error": "none"}
        jobID = kw['jobid']
        jobDate = kw['jobdate']
        jobDesc = kw['jobdesc']
        state = kw['state']
        name = kw['name']
        latitude = kw['latitude']
        longitude = kw['longitude']
        print("ID:{}".format(jobID))
        print("date:{}".format(jobDate))
        print("Description:{}".format(jobDesc))
        print("name:{}".format(name))
        print("state:{}".format(state))
        print("latitude:{}".format(latitude))
        print("longitude:{}".format(longitude))
        if state != "Assigned":
            dday = jobDate[8:10]
            ntime = jobDate[16:24]
            dyear = jobDate[11:15]
            dmonth = a2m(jobDate[4:7])
            newdate = dyear + "/" + dmonth + "/" + dday
            print("time:{}".format(jobDate[16:24]))
            sjobdate = newdate + " " + jobDate[16:24]
            print("S Date:{}".format(sjobdate))
            jobdate = datetime.strptime(sjobdate, '%Y/%m/%d %H:%M:%S')
            # store data in Job Table
            query = DBSession.query(Jobs).filter_by(gate_user=name,
                                                    job_id=jobID).first()
            if query is None:
                newitem = Jobs()
                newitem.job_id = jobID
                newitem.job_date = jobdate
                newitem.job_description = jobDesc
                newitem.job_state = state
                newitem.latitude = float(latitude)
                newitem.longitude = float(longitude)
                newitem.last_update = datetime.now()
                newitem.gate_user = name
                DBSession.add(newitem)
                DBSession.flush()
            else:
                query.job_date = jobdate
                query.job_description = jobDesc
                query.job_state = state
                query.latitude = float(latitude)
                query.longitude = float(longitude)
                query.last_update = datetime.now()
                DBSession.flush()

            print("Date:{}".format(newdate))
            query = DBSession.query(Smartphones).filter_by(
                gate_user=name).first()
            if query is not None:
                # Send Message
                data_message = {
                    "command": "message",
                    "title": newdate,
                    "body": jobDesc
                }
                # apikey=os.environ.get('FCM_KEY') or "AIzaSyAw5EFGDer7-PEuXXMzYNPwla9RP2SVqz4"
                apikey = "AIzaSyCxiYxZsSqKGaJ4NM7vM4yP9d0BYlQcNmo"
                push_service = FCMNotification(api_key=apikey)
                resp = push_service.notify_single_device(
                    registration_id=query.token, data_message=data_message)
                # Update Data
                print("Send newjob")
                data_message = {
                    "command": "newjob",
                    "jobnumber": jobID,
                    "jobdate": newdate,
                    "jobtime": ntime,
                    "jobdesc": jobDesc,
                    "joblat": latitude,
                    "joblon": longitude,
                    "jobstate": state
                }
                push_service = FCMNotification(api_key=apikey)
                resp = push_service.notify_single_device(
                    registration_id=query.token, data_message=data_message)
            Message.post("Smartphonesfrom", 'RELOAD' + "|")
        return error
Beispiel #12
0
def multiple_devices_data_message(registration_ids: RegistrationIds,
                                  data_message: dict, **kwargs):
    push_service = FCMNotification(api_key=settings.FCM_API_KEY)
    return push_service.multiple_devices_data_message(
        registration_ids=registration_ids, data_message=data_message, **kwargs)
Beispiel #13
0
def single_device_data_message(registration_id: str, data_message: dict,
                               **kwargs):
    push_service = FCMNotification(api_key=settings.FCM_API_KEY)
    return push_service.single_device_data_message(
        registration_id=registration_id, data_message=data_message, **kwargs)
Beispiel #14
0
from pyfcm import FCMNotification

push_service = FCMNotification(
    api_key=
    "AAAADr-ZRdI:APA91bG47NnjmLN_CWmWZ1aDfsW3UC5JkrFzzaM4WrGA0O54eZQzZZ50pn52n0swqbK2TG9_b-B6rGuQQFRRrq7dhVqmaxILGQhei8mreDolGDrFpMTCO0sLRGJ7-Z1OYtzVUVieGmMt"
)

data_message = {
    "payload": {
        "title": "Example",
        "alert": "Sample alert",
        "icon": "little_star",
        "badge": "2",
        "sound": "door_bell",
        "vibrate": True
    }
}

registration_id = "APA91bER9gvLorSy2hp-hrP413Pv2ARZLM0Hy8IEkKbm86wSd2VGo3FWLOQFNSUAcR7y788deqK3iBrnH6iXGCfGakJ5NWsowcVATcbs-m88vIlxiTbKOSAVnYdgM4eoJAfdmdrYvSfK"
message_title = "Test FCM"
message_body = "Hello Nuibb Vai!!"

result = push_service.single_device_data_message(
    registration_id=registration_id, data_message=data_message)

print(result)
from pyfcm import FCMNotification

APIKEY = "AAAAsLhtlp8:APA91bF7A7f_Rr0tBhpZmgBAzZ5wAIGifzAyMtLJgerJyR-uX6t6bdpjyZ6dNE1IDOk22wm3vItH9xx4mZwzzI_4lcbGBJ-ZBi8kHh9Cxwf_2Kb14SUAnDPkCFPZhHGEP-pdYEeucLfS"

# 파이어베이스 콘솔에서 얻어 온 서버 키를 넣어 줌
push_service = FCMNotification(APIKEY)


def sendMessage(body, title):
    # 메시지 (data 타입)
    data_message = {"body": body, "title": title}

    # topic을 이용해 다수의 구독자에게 푸시알림을 전송함
    result = push_service.notify_topic_subscribers(topic_name="generalTopic",
                                                   data_message=data_message)

    # 전송 결과 출력
    print(result)


sendMessage("TEST Message", "데이터 업데이트 알림")
Beispiel #16
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'olucurious'
from pyfcm import FCMNotification

push_service = FCMNotification(api_key="<api-key>")
registration_id = "<device registration_id>"
message = "Hope you're having fun this weekend, don't forget to check today's news"
result = push_service.notify_topic_subscribers(topic_name="global",
                                               message_body=message)
print(result)
Beispiel #17
0
import time
import re

from pyfcm import FCMNotification
import pyfcm

from backend.api_keys import fcm_key
from backend.log_util import log

firebase_fcm = FCMNotification(api_key=fcm_key)


def send_fcm(feed, debug=False):
    global firebase_fcm
    message = feed.desc
    title = feed.title
    # game = None
    if feed.scope == "uploadplan":
        message = get_uploadplan_from_desc(feed.desc)
        if len(re.findall(".*?<br.*?>", message)) > 6:
            message = "<i>Diese Vorschau ist möglicherweise unvollständig:</i><br/>" + message
    elif feed.scope == "video":
        # Only send the title of the video (as message)
        title = "Neues Video (pietsmiet.de)"
        message = feed.title
        # game = get_game_from_video(message)
    elif feed.scope == "news":
        # Only send the title of the news item (as message)
        title = "News (pietsmiet.de)"
        message = feed.title
Beispiel #18
0
import requests, os
import time
#import telegram
from selenium import webdriver
from pymongo import MongoClient
from pyfcm import FCMNotification
from bs4 import BeautifulSoup

push_service = FCMNotification(
    api_key="AIzaSyAeG8serpElJCe7URp2ab3liN0IBMqlTAA")

registration_id1 = 'dV_zajKmr8Y:APA91bFHtuH2YU3eTplSqDSDtSbwXuxq__n__EfHpRMPbwe2FSGXMdjG8giZ-mgE9_9HWVtGvBkiYq6YKX1dr9ivtDJYwxMCNCI2N5i1D0EC69Py_3JUQfxX9ybfG_7U7g5FIdNwXsoz'

client = MongoClient(
    'mongodb://*****:*****@ds013475.mlab.com:13475/heroku_4s0bvwj7')
db = client.heroku_4s0bvwj7

# path = 'http://www.e-pass.co.kr/event/new.asp'

# html = requests.get(path)
# soup = BeautifulSoup(html.content, 'html.parser', from_encoding='utf-8')
# tag_list = soup.find_all('tr',{"height":28})

href = 'new_info.asp?Posi=Home&AdType=Tag&Mode=Event&SMode=New&Cmd=&S_Year=&S_Month=&S_Day=&Page=1&InNo=2018-02-14-120&MF=0&L_URL=/event/new.asp&D_URL=/event/new_info.asp&ApplyChk='
# 14-120
print(href)

downloadPaht = 'http://www.e-pass.co.kr/event/' + href

browser = webdriver.PhantomJS()
Beispiel #19
0
def fcm_send_message(registration_id,
                     title=None,
                     body=None,
                     icon=None,
                     data=None,
                     sound=None,
                     badge=None,
                     low_priority=False,
                     condition=None,
                     time_to_live=None,
                     click_action=None,
                     collapse_key=None,
                     delay_while_idle=False,
                     restricted_package_name=None,
                     dry_run=False,
                     color=None,
                     tag=None,
                     body_loc_key=None,
                     body_loc_args=None,
                     title_loc_key=None,
                     title_loc_args=None,
                     content_available=None,
                     extra_kwargs={},
                     api_key=None,
                     json_encoder=None,
                     extra_notification_kwargs=None,
                     **kwargs):
    """
    Copied from https://github.com/olucurious/PyFCM/blob/master/pyfcm/fcm.py:

    Send push notification to a single device
    Args:
        registration_id (str): FCM device registration IDs.
        body (str): Message string to display in the notification tray
        data (dict): Data message payload to send alone or with the notification
            message
        sound (str): The sound file name to play. Specify "Default" for device
            default sound.
    Keyword Args:
        collapse_key (str, optional): Identifier for a group of messages
            that can be collapsed so that only the last message gets sent
            when delivery can be resumed. Defaults to ``None``.
        delay_while_idle (bool, optional): If ``True`` indicates that the
            message should not be sent until the device becomes active.
        time_to_live (int, optional): How long (in seconds) the message
            should be kept in FCM storage if the device is offline. The
            maximum time to live supported is 4 weeks. Defaults to ``None``
            which uses the FCM default of 4 weeks.
        low_priority (boolean, optional): Whether to send notification with
            the low priority flag. Defaults to ``False``.
        restricted_package_name (str, optional): Package name of the
            application where the registration IDs must match in order to
            receive the message. Defaults to ``None``.
        dry_run (bool, optional): If ``True`` no message will be sent but
            request will be tested.

    Returns:
        :tuple:`multicast_id(long), success(int), failure(int),
            canonical_ids(int), results(list)`:
        Response from FCM server.
    Raises:
        AuthenticationError: If :attr:`api_key` is not set or provided or there
            is an error authenticating the sender.
        FCMServerError: Internal server error or timeout error on Firebase cloud
            messaging server
        InvalidDataError: Invalid data provided
        InternalPackageError: JSON parsing error, mostly from changes in the
            response of FCM, create a new github issue to resolve it.
    """
    if api_key is None:
        api_key = SETTINGS.get("FCM_SERVER_KEY")
    push_service = FCMNotification(api_key=api_key, json_encoder=json_encoder)
    result = push_service.notify_single_device(
        registration_id=registration_id,
        message_title=title,
        message_body=body,
        message_icon=icon,
        data_message=data,
        sound=sound,
        badge=badge,
        collapse_key=collapse_key,
        low_priority=low_priority,
        condition=condition,
        time_to_live=time_to_live,
        click_action=click_action,
        delay_while_idle=delay_while_idle,
        restricted_package_name=restricted_package_name,
        dry_run=dry_run,
        color=color,
        tag=tag,
        body_loc_key=body_loc_key,
        body_loc_args=body_loc_args,
        title_loc_key=title_loc_key,
        title_loc_args=title_loc_args,
        content_available=content_available,
        extra_kwargs=extra_kwargs,
        extra_notification_kwargs=extra_notification_kwargs,
        **kwargs)

    # do not raise errors, pyfcm will raise exceptions if response status will
    # be anything but 200

    return result
# Send to single device.
from pyfcm import FCMNotification

push_service = FCMNotification(api_key="AAAAN6nlb4k:APA91bHxb_WUirlGQjXKhYGCyFgTR4YIUZi8IYKxWPzrJaQ3ohGswHFwxUC1BQ8demw6e8adpHjXdnVOBEVgI68BFtLQha5nJuq0tgigPm3MJbAFGnsF7fYxakauDYv8xOpJryVJgnEL")


# Your api-key can be gotten from:  https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging

registration_id = "cHJUNmCDXA0:APA91bE67420iQzEEQ3CBoYnsuPzF_B8Jxe1vUXnKPDeIiHTet1NOCaFQNa3GqLClt1kRrYNggFvTTKK8Q6KlH2-kiqNxAkWukKc2XbSawlLQFkPi1o21j8PfCIVarSkXNi4_82lqeXj"
message_title = "Hello"
message_body = "FireMessage"
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)
print (result)
from pyfcm import FCMNotification

push_service = FCMNotification(api_key="Server Api KEY under cloud messaging on Firebase console")

# OR initialize with proxies

# proxy_dict = {
#           "http"  : "http://127.0.0.1",
#           "https" : "http://127.0.0.1",
#         }
# push_service = FCMNotification(api_key="Server Api KEY under cloud messaging on Firebase console", proxy_dict=proxy_dict)

# Your api-key can be gotten from:  https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging


# -------------------------------------Single device--------------------------------------------------

 registration_id = "Device registration_id / token generated on Android and iOS device."
 message_title = "Test Notification"
 message_body = "Hi Akshay, your customized news for today is ready"
 result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)

 print(result)
# --------------------------------------End Single device -----------------------------------------

# Send to multiple devices by passing a list of ids.

registration_id1 = "Device registration_id / token generated on Android and iOS device."
registration_id2 = "Device registration_id / token generated on Android and iOS device."

registration_ids = [registration_id1, registration_id2]
Beispiel #22
0
	def __init__(self, bucket, conf):
		self.bucket = bucket
		self.conf = conf
		self.push_service = FCMNotification(api_key=conf["api_key"])
Beispiel #23
0
from pyfcm import FCMNotification

push_service = FCMNotification(api_key="")  #Enter API key

# Your api-key can be gotten from:  https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging

registration_id = ""  #Enter Reg ID of the user.
data_message = {
    "notificationId": "inactivity",  #Should be unique for a notification.
    "source": "firebase",
    "addTags": ["4DayInactive"]  #Place tag to the user
}

result = push_service.notify_single_device(registration_id=registration_id,
                                           data_message=data_message)
print result
Beispiel #24
0
from pyfcm import FCMNotification

push_service = FCMNotification(
    api_key="AIzaSyABB-A2ttgLvA0HEMUgfVfbLD9CwqNJgDA")

# Your api-key can be gotten from:  https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging

registration_id = "dTiF1KGahSo:APA91bHcP0affwYlLqBp_yemQ2Rg057aqTXKzurIX_1SZ9tcclRLc90r7fvCS0q_Evj69YGVwsQ6cv-a8v75q4dY8cvUwjOWEF8TGcoLu7Pp3NS8x5HUZmzpghkIVhJCeTKti1CGpnGQ"
message_title = "Uber update"
message_body = "Hi john, your customized news for today is ready"
result = push_service.notify_single_device(registration_id=registration_id,
                                           message_title=message_title,
                                           message_body=message_body)

print result
def get_push_service(api_key=None):
    return FCMNotification(api_key=api_key or system_settings.FIREBASE_FCM_KEY)
Beispiel #26
0
 def __init__(self, fcm_notification=None, executor=None):
     if not fcm_notification:
         fcm_notification = FCMNotification(api_key=settings.FCM_API_KEY,
                                            proxy_dict=settings.FCM_PROXY)
     self._executor = executor or ThreadPoolExecutor()
     self._push = fcm_notification
Beispiel #27
0
import blescan
import sys
from firebase import firebase
import bluetooth._bluetooth as bluez
import sqlite3
import datetime
from pyfcm import FCMNotification

#firebase

api_key="AAAA_4CCsfU:APA91bFyBB2Rm4JDT4rHez2lgxgmqun1AytQH0VIZ7ux_WQnhlFs6T68HniZSrr22i4m1KfaNZcSktUWbkjN-aj0sodI74NC5ifHaacMhT6v651WCOc-l3-8_wY5cFFb_iyiLCxM-oC-"
push_service = FCMNotification(api_key=api_key)

#sqlite
conn = sqlite3.connect('db/bl_log.db')


def insert_log(bl_log_data):
    sql = ''' INSERT INTO Log(CustomerName,MacAdress,InsertDate)
              VALUES(?,?,?) '''
    cur = conn.cursor()
    cur.execute(sql, bl_log_data)

def insert_anon_log(bl_log_data):
    sql = ''' INSERT INTO Log_Anonymus(Mac,InsertedDate)
              VALUES(?,?) '''
    cur = conn.cursor()
    cur.execute(sql, bl_log_data)

Beispiel #28
0
from django.conf import settings
from django.contrib.auth import get_user_model

from celery import shared_task
from pyfcm import FCMNotification

from users.models import Notifications

push_service = FCMNotification(api_key=settings.FCM_APIKEY)

User = get_user_model()

users = User.objects.filter(company__isnull=True).order_by('?')


@shared_task
def send_notifications_2_users(users_count, message):
    notification_users = users[:users_count]
    for notification_user in notification_users:
        try:
            result = push_service.notify_topic_subscribers(
                topic_name=notification_user.phone,
                message_body=message,
                sound="Default",
                tag='true')
            print(result)
        except:
            print('cannot sent')
            pass

Beispiel #29
0
#!/usr/bin/python3

from pyfcm import FCMNotification

API_KEY = "AAAAWFdQKTY:APA91bFXnXpVIIjjZ9S4ajRVJW1FmzNUrsxPA51F8LP2n9MAwhvoX0lZQ1BOhZ5re7SANnol8qQ4xSaqSo-qCYFWCyMsqkTH4N__LwiEdzmKJYvYrImSAudDH86V8ni7n3t7ySw__cE-EVuA2FqRjsghCTn-I_E_zg"

push_service = FCMNotification(api_key=API_KEY)

# result = push_service.notify_topic_subscribers(
#     topic_name="ioi2017",
#     message_title="IOI 2018 — Tsukuba, Japan",
#     message_body="The contest is finished! Tap to see the final ranking.",
#     sound="Default")

result = push_service.notify_topic_subscribers(
    topic_name="ioi2017",
    message_title="Joseph's score increased!",
    message_body=
    "The contestant Joseph Benton (GBR-3) has submitted a 50pt solution to the task 'books', increasing their score by +28pt!",
    sound="Default")

print(result)
import paho.mqtt.client as mqtt
import sqlite3
from pyfcm import FCMNotification
import json
from datetime import date, datetime
import time

#----------------------------------------------------------------------

push_service = FCMNotification(
    api_key=
    "AAAAj7P1O5g:APA91bHUCdu3Pf3pdewj2co-rQO9yFwkWjTm2FKbvHNrMZwrWw6KZ2OUDy_sdilVTXTdBg7KqWh6EH3rt6P34CXNpYrdgSC3eJMPjY-iwx_a5rXXmPCCCUITurpYLpl-Kfe2rz2oNHBn"
)

broker_address = "35.225.183.19"
port = 1883  #portNumber
#user = "******"
#password = "******"
topic = "getSlotDetails"
#----------------------------------------------------------------------


def billing_system():
    connect()
    client = mqtt.Client('as6g54er6has4')
    client.on_connect = on_connect
    client.on_message = on_message
    client.connect(broker_address, port, 60)
    #client.on_log=on_log
    client.loop_forever()