共用方式為


建立通知中樞

建立新的通知中樞,其中包含支援的 Platform Notification Services (WNS、APNS、GCM) 認證。

要求

方法 要求 URI HTTP 版本
PUT https://{namespace}.servicebus.windows.net/{Notification Hub}?api-version=2015-01 HTTP/1.1

要求標頭

下表描述必要的和選用的要求標頭。

要求標頭 描述
Content-Type application/xml;type=entry;charset=utf-8
授權 使用 服務匯流排共用存取簽章驗證中所指定的 SAS 權杖。
x-ms-version 2015-01

要求本文

要求本文包含具有 NotificationHubDescription 元素的 Atom 專案。 例如:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
    <NotificationHubDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
        <ApnsCredential>
            <Properties>
                <Property>
                    <Name>Endpoint</Name> 
                    <Value>gateway.push.apple.com</Value> 
                </Property>
                <Property>
                    <Name>ApnsCertificate</Name> 
                    <Value>{APNS certificate in Base64}</Value> 
                </Property>
                <Property>
                    <Name>CertificateKey</Name> 
                    <Value>{APNS certificate key}</Value> 
                </Property>
            </Properties>
        </ApnsCredential>
        <RegistrationTtl>P39D</RegistrationTtl> 
        <WnsCredential>
            <Properties>
                <Property>
                    <Name>PackageSid</Name> 
                    <Value>{PackageSid}</Value> 
                </Property>
                <Property>
                    <Name>SecretKey</Name> 
                    <Value>{SecretKey}</Value> 
                </Property>
            </Properties>
        </WnsCredential>
        <GcmCredential>
            <Properties>
                <Property>
                    <Name>GoogleApiKey</Name> 
                    <Value>{ApiKey}</Value> 
                </Property>
            </Properties>
        </GcmCredential>
        <MpnsCredential>
            <Properties>
                <Property>
                    <Name>MpnsCertificate</Name> 
                    <Value>{MPNS certificate in Base64}</Value> 
                </Property>
                <Property>
                    <Name>CertificateKey</Name> 
                    <Value>{MPNS certificate key}</Value> 
                </Property>
            </Properties>
        </MpnsCredential>
    </NotificationHubDescription>
</content></entry>

ApnsCredential 的端點屬性可以是 gateway.push.apple.com 生產伺服器) (或 gateway.sandbox.push.apple.com 沙箱伺服器) 的 (。

NotificationHubDescription 的所有子項目都是選擇性的。

WNS、APNS 和 GCM 認證必須包含上述所有屬性。 MPNS 認證也可以包含任何屬性,可針對 MPNS 啟用未經驗證的推送。

回應

回應包括 HTTP 狀態碼和一組回應標頭。

回應碼

程式碼 描述
201 已成功建立通知主題。
400 無效的要求內文。 無法建立通知主題,因為要求格式不正確 (或驗證失敗) 。
401 授權失敗。 存取金鑰不正確。
403 超過配額;此命名空間中的通知中樞太多。 未建立通知中樞。
409 節點已經包含另一個實體。

如需狀態碼的相關資訊,請參閱 狀態和錯誤碼

回應標頭

無。

回應本文

NotificationHubDescription 元素,其中包含目前節點中定義的所有原則。