Sdílet prostřednictvím


Vytvoření registrace

Vytvoří novou registraci. Tato metoda vygeneruje ID registrace, které můžete následně použít k načtení, aktualizaci a odstranění této registrace.

Žádost

Metoda Identifikátor URI žádosti Verze PROTOKOLU HTTP
POST https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/?api-version=2015-01 HTTP/1.1

Hlavičky požadavku

Následující tabulka popisuje požadované a volitelné hlavičky požadavků.

Hlavička požadavku Popis
Typ obsahu application/atom+xml;type=entry;charset=utf-8
Autorizace Token SAS vygenerovaný podle specifikace v části Ověřování pomocí sdíleného přístupového podpisu pomocí služby Service Bus.
x-ms-version 2015-01

Text požadavku

Položka Atom s popisem vloženým v obsahu. Následují některé příklady.

Nativní registrace pro Službu oznámení systému Windows:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <WindowsRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <ChannelUri>{ChannelUri}</ChannelUri>
        </WindowsRegistrationDescription>
    </content>
</entry>

Poznámka

Element Tags je volitelný.

Registrace šablony pro Službu oznámení systému Windows:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <WindowsTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <ChannelUri>{ChannelUri}</ChannelUri>
            <BodyTemplate><![CDATA[{Template for the body}]]></BodyTemplate>
            <WnsHeaders>
                <WnsHeader>
                    <Header>X-WNS-Type</Header>
                    <Value>wns/tile</Value>
                </WnsHeader>
                <WnsHeader>
                    <Header>X-WNS-Tag</Header>
                    <Value>myTag</Value>
                </WnsHeader>
            </WnsHeaders>
        </WindowsTemplateRegistrationDescription>
    </content>
</entry>

Poznámka

Element BodyTemplate je povinný, stejně jako hlavička X-WNS-Type.

Nativní registrace pro službu Apple Push Notification Service:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <AppleRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <DeviceToken>{DeviceToken}</DeviceToken> 
        </AppleRegistrationDescription>
    </content>
</entry>

Poznámka

Element Tags je volitelný.

Registrace šablony pro službu Apple Push Notification Service:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <AppleTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <DeviceToken>{DeviceToken}</DeviceToken>
            <BodyTemplate><![CDATA[{Template for the body}]]></BodyTemplate>
            <Expiry>{Template for Expiry in }</Expiry>
        </AppleTemplateRegistrationDescription>
    </content>
</entry>

Poznámka

Element BodyTemplate je povinný. Vypršení platnosti je volitelné.

Nativní registrace pro službu Firebase Cloud Messaging:

// FcmV1Registration 
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <FcmV1RegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <FcmV1RegistrationId>{deviceToken}</FcmV1RegistrationId>
        </FcmV1RegistrationDescription>
    </content>
</entry>

Nativní registrace služby Google Cloud Messaging:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <GcmRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <GcmRegistrationId>{GCM Registration Id}</GcmRegistrationId> 
        </GcmRegistrationDescription>
    </content>
</entry>

Poznámka

Element Tags je volitelný.

Registrace šablony pro službu Firebase Cloud Messaging:

// FcmV1TemplateRegistration 
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <FcmV1TemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <FcmV1RegistrationId>{deviceToken}</FcmV1RegistrationId>
            <BodyTemplate><![CDATA[ {BodyTemplate}]]></BodyTemplate>
        </FcmV1TemplateRegistrationDescription>
    </content>
</entry>

Registrace šablony pro službu Google Cloud Messaging:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <GcmTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <GcmRegistrationId>{GCM Registration Id}</GcmRegistrationId> 
            <BodyTemplate><![CDATA[ {BodyTemplate}]]></BodyTemplate>
        </GcmTemplateRegistrationDescription>
    </content>
</entry>

Poznámka

Element BodyTemplate je povinný.

Nativní registrace pro službu nabízených oznámení Microsoftu:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <MpnsRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <ChannelUri>{ChannelUri}</ChannelUri>
        </MpnsRegistrationDescription>
    </content>
</entry>

Poznámka

Element Tags je volitelný.

Registrace šablony pro službu Microsoft Push Notification Service:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/xml">
        <MpnsTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
            <Tags>myTag, myOtherTag</Tags>
            <ChannelUri>{ChannelUri}</ChannelUri>
            <BodyTemplate><![CDATA[{Template for the body}]]></BodyTemplate>
            <MpnsHeaders>
                <MpnsHeader>
                    <Header>X-WindowsPhone-Target</Header>
                    <Value>toast</Value>
                </MpnsHeader>
                <MpnsHeader>
                    <Header>X-NotificationClass</Header>
                    <Value>[batching interval]</Value>
                </MpnsHeader>
            </MpnsHeaders>
        </MpnsTemplateRegistrationDescription>
    </content>
</entry>

Poznámka

Element BodyTemplate je povinný, stejně jako hlavička X-WindowsPhone-Target.

Odpověď

Odpověď obsahuje stavový kód HTTP a sadu hlaviček odpovědi.

Kódy odpovědí

Kód Description
201 Registrace se úspěšně vytvořila.
400 Neplatný text požadavku. Registraci nelze vytvořit, protože požadavek byl poškozen.
401 Autorizace se nezdařila. Přístupový klíč byl nesprávný.
403 Překročení kvóty; příliš mnoho registrací v tomto oboru názvů. Registrace se nevytvořila.
403 Žádost byla odmítnuta, protože rychlost operací registrace je příliš vysoká.

Informace o stavových kódech najdete v tématu Stavové kódy a kódy chyb.

Hlavičky odpovědi

Hlavička odpovědi Description
Typ obsahu application/atom+xml;type=entry;charset=utf-8
Etag {weak ETag}

Text odpovědi

Po úspěchu se vrátí ověřená položka Atom. Obsahuje prvky jen pro čtení, jako jsou ETag, RegistrationId a ExpirationTime. Příklad:

<entry>
    <id>https://{tenant}.servicebus.windows.net/{NotificationHub}/registrations/{registrationId}</id>
    <title type="text"> /{NotificationHub}/registrations/{registrationId}</title>
    <updated>2012-08-17T17:32:00Z</updated>
    <metadata:etag>{weak Etag}</metadata:etag>
    <content type="application/xml">
    <WindowsRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
        <ETag>{ETag}</ETag>
        <ExpirationTime>2012-07-16T19:20+01:00</ExpirationTime>
        <RegistrationId>{RegistrationId}</RegistrationId>
            <Tags>myTag, myOtherTag</Tags>
            <ChannelUri>{ChannelUri}</ChannelUri>
        </WindowsRegistrationDescription>
    </content>
</entry>