Exemple #1
0
def list_topics(token, app_id=None):
    """
    :param token: The token to be queried
    :param app_id: application ID
    """
    try:
        response = push_admin.get_app(app_id).query_subscribe_list(token)
        return TopicQueryResponse(response)
    except Exception as e:
        raise ApiCallError(repr(e))
Exemple #2
0
def unsubscribe_topic(topic, token_list, app_id=None):
    """
    :param topic: The specific topic
    :param token_list: The token list to be deleted
    :param app_id: application ID
    """
    try:
        response = push_admin.get_app(app_id).unsubscribe_topic(topic, token_list)
        return TopicSubscribeResponse(response)
    except Exception as e:
        raise ApiCallError(repr(e))
Exemple #3
0
def send_message(message, validate_only=False, app_id=None):
    """
        Sends the given message Huawei Cloud Messaging (HCM)
        :param message: An instance of ``messaging.Message``.
        :param validate_only: A boolean indicating whether to run the operation in dry run mode (optional).
        :param app_id: app id parameters obtained by developer alliance applying for Push service (optional).
        :return: SendResponse
        Raises:
            ApiCallError: If an error occurs while sending the message to the HCM service.
    """
    try:
        response = push_admin.get_app(app_id).send(message, validate_only)
        return SendResponse(response)
    except Exception as e:
        raise ApiCallError(repr(e))