def send_push_android_data_message():
    """
    a sample to show hwo to send web push message
    :return:
    """
    message = messaging.Message(
        # English sample
        # data = "{\"pushtype\":0,\"pushbody\":{\"title\":\"Welcome to use Huawei HMS Push Kit?\",\"description\":\"One "
        #       + "of the best push platform on the planet!!!\",\"page\":\"/\",\"params\":{\"key1\":\"test1\",\"key2\":\"test2\"},\"ringtone\":"
        #       + "{\"vibration\":\"true\",\"breathLight\":\"true\"}}}",
        # Chinese sample
        data=
        "{\"pushtype\":0,\"pushbody\":{\"title\":\"欢迎使用华为HMS Push Kit!\",\"description\":\"世界上最好,"
        +
        "最优秀的推送平台!!!\",\"page\":\"/\",\"params\":{\"key1\":\"test1\",\"key2\":\"test2\"},\"ringtone\":"
        + "{\"vibration\":\"true\",\"breathLight\":\"true\"}}}",
        android=android,
        token=['your token'])

    try:
        response = messaging.send_message(message)
        print "response is ", json.dumps(vars(response))
        assert (response.code == '80000000')
    except Exception as e:
        print repr(e)
Esempio n. 2
0
def send_apns_push_message():
    """
    a sample to show hwo to send web push message
    :return:
    """
    message = messaging.Message(apns=apns_push_config, token=['your token'])

    try:
        response = messaging.send_message(message)
        print "response is ", json.dumps(vars(response))
        assert (response.code == '80000000')
    except Exception as e:
        print repr(e)
Esempio n. 3
0
def send_push_android_notify_message():
    """
    a sample to show hwo to send web push message
    :return:
    """
    message = messaging.Message(notification=notification,
                                android=android,
                                token=[push_env.test_device_token])

    try:
        response = messaging.send_message(message)
        print("response is ", json.dumps(vars(response)))
        assert (response.code == '80000000')
    except Exception as e:
        print(repr(e))
Esempio n. 4
0
def send_push_android_data_message():
    """
    a sample to show hwo to send web push message
    :return:
    """
    message = messaging.Message(data="{'k1':'v1', 'k2':'v2'}",
                                android=android,
                                token=['your token'])

    try:
        response = messaging.send_message(message)
        print "response is ", json.dumps(vars(response))
        assert (response.code == '80000000')
    except Exception as e:
        print repr(e)
def send_push_android_data_message():
    """
    a sample to show hwo to send web push message
    :return:
    """
    message = messaging.Message(notification=notification,
                                android=android,
                                topic='topic1')

    try:
        response = messaging.send_message(message)
        print "response is ", json.dumps(vars(response))
        assert (response.code == '80000000')
    except Exception as e:
        print repr(e)