你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
创建通知中心
创建新的通知中心,其中包含支持的平台通知服务(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 元素。