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

com.windowsazure.messaging.MpnsNotification 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 Windows Phone notification.
 */
public class MpnsNotification extends Notification {

    /**
     * Creates a new instance of the MpnsNotification class.
     * @param body The XML body for the Windows Phone PNS.
     */
    public MpnsNotification(String body) {
        this.body = body;

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

        if (body.contains("")) {
            this.headers.put("X-WindowsPhone-Target", "toast");
            this.headers.put("X-NotificationClass", "2");
        }
        if (body.contains("")) {
            this.headers.put("X-WindowsPhone-Target", "tile");
            this.headers.put("X-NotificationClass", "1");
        }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy