示例#1
0
def send(data, device_gcm_tokens = [], device_pns_tokens = [], badge_nums = None, test_cert = None, i_data=None):
    """
    Takes a list of android gcm tokens, apple pns tokens.
    Badge nums are specific to apple only, and must be in the same order as the device pns tokens
    """
    #Make sure 'message' is set for legacy app purpose
    if data.get('msg') and not data.get('message'):
        data['message'] = data.get('msg')
    device_gcm_tokens = [gcm_token for gcm_token in device_gcm_tokens if gcm_token] #Weed out the null's
    device_pns_tokens = [pns_token for pns_token in device_pns_tokens if pns_token] #Weed out the null's
    if device_gcm_tokens:
        send_android(device_gcm_tokens, data)
    if device_pns_tokens:  # push to both, if both are registered
        # If we have a specific iphone data set to use
        if i_data:
            send_ios(device_pns_tokens, i_data, badge_nums, test_cert)
        else:
            send_ios(device_pns_tokens, data, badge_nums, test_cert)
示例#2
0
def send_ios_notification(request):
    message = request.GET.get("message")
    token = request.GET.get("token", "04f63ec7853e20ddf079b77d6c8a33d30395901d9d334c8ae0d0760d8fbdc23b")
    response_data = send_ios([token], {"message": message, "badge": 1})

    return response_data