コード例 #1
0
def send_notification(account_id, message):
    with app.app_context():
        api_key = app.config['GCM_API_KEY']
        tokens = AccessToken.query.filter_by(account_id=account_id).distinct(AccessToken.push_token).all()

    notification = {
        'title': 'GitHub Activity',
        'body': message
    }

    for token in tokens:
        if token.push_token:
            send_message(api_key, token.push_token, notification=notification)
コード例 #2
0
ファイル: misc.py プロジェクト: hackathon-5/we-are-root-repo
def send_notification():
    api_key = current_app.config['GCM_API_KEY']
    tokens = AccessToken.query.filter_by(account_id=g.account_id).distinct(AccessToken.push_token).all()

    notification = {
        'title': 'hello',
        'body': 'wooooooo works'
    }

    for token in tokens:
        if token.push_token:
            send_message(api_key, token.push_token, notification=notification)

    return jsonify({'hello': g.name})