All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.windowsazure.messaging.WindowsNotification Maven / Gradle / Ivy

Go to download

Azure Notification Hubs Java SDK for interacting with the data and management plane operations.

The newest version!
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------

package com.windowsazure.messaging;

import org.apache.hc.core5.http.ContentType;

/**
 * This class represents a notification for WNS.
 */
public class WindowsNotification extends Notification {

    /**
     * Creates a new instance of the WindowsNotification class.
     * @param body The XML or raw body for WNS.
     */
    public WindowsNotification(String body) {
        this.body = body;

        this.headers.put("ServiceBusNotification-Format", "windows");

        if (body.matches("\\s*[\\s\\S]+$"))
            this.headers.put("X-WNS-Type", "wns/toast");
        if (body.matches("\\s*[\\s\\S]+$"))
            this.headers.put("X-WNS-Type", "wns/tile");
        if (body.matches("\\s*[\\s\\S]+$"))
            this.headers.put("X-WNS-Type", "wns/badge");

        if (body.startsWith("<")) {
            this.contentType = ContentType.APPLICATION_XML;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy