This article will introduce how to use Azure Notification Hub REST API to send a notification to device with Baidu Push. It provides an example of how to retrieve the PNS handle and send notification to device using REST API with Baidu Push.
Pre-requirement :
Before starting, you must setup a Baidu Push environment and create a application in Android Studio.
Getting started with Azure Notification Hub using Baidu
Method |
Request URI |
POST |
https://<notification_hub_namespace>.servicebus.windows.net/<notification_hub_name>/registrations/?api-version=2015-01 |
Request Header |
Description |
Content-Type |
application/atom+xml;type=entry;charset=utf-8 |
Authorization |
Azure Service Bus access control with Shared Access Signatures - Azure Service Bus | Microsoft Docs |
x-ms-version |
2015-01 |
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns=http://www.w3.org/2005/Atom>
<content type="application/xml">
<BaiduRegistrationDescription xmlns:i=http://www.w3.org/2001/XMLSchema-instance xmlns=http://schemas.microsoft.com/netservices/2010/10/servicebus/connect>
<BaiduUserId>{userId}</BaiduUserId>
<BaiduChannelId>{channelId}</BaiduChannelId>
</BaiduRegistrationDescription >
</content>
</entry>
Code |
Description |
200 |
Registration created successfully. |
<entry a:etag="W/"1"" xmlns=http://www.w3.org/2005/Atom xmlns:a=http://schemas.microsoft.com/ado/2007/08/dataservices/metadata>
<id>https://notificationhubn.servicebus.windows.net/notificationhub1/registrations/{registerId}?api-version=2015-01</id>
<title type="text">{registerId}</title>
<published>2021-02-19T06:52:22Z</published>
<updated>2021-02-19T06:52:22Z</updated>
<link rel="self" href=https://notificationhubn.servicebus.windows.net/notificationhub1/registrations/{registerId}?api-version=2015-01/>
<content type="application/xml">
<BaiduRegistrationDescription xmlns=http://schemas.microsoft.com/netservices/2010/10/servicebus/connect xmlns:i=http://www.w3.org/2001/XMLSchema-instance>
<ETag>1</ETag>
<ExpirationTime>9999-12-31T23:59:59.999</ExpirationTime>
<RegistrationId>{registerId}</RegistrationId>
<BaiduUserId>{userId}</BaiduUserId>
<BaiduChannelId>{channelId}</BaiduChannelId>
</BaiduRegistrationDescription>
</content>
</entry>
Method |
Request URI |
POST |
https://<notification_hub_namespace>.servicebus.windows.net/<notification_hub_name>/messages/?api-version=2015-04 |
Request Header |
Description |
Content-Type |
application/json;charset=utf-8 |
Authorization |
Azure Service Bus access control with Shared Access Signatures - Azure Service Bus | Microsoft Docs |
ServiceBusNotification-DeviceHandle |
{RegistrationId} |
ServiceBusNotification-Format |
baidu |
x-ms-version |
2015-04 |
{"title":"Title","description":"Notification Hub test notification"}
- Response Code
Code |
Description |
201 |
Message successfully send to Baidu. |
Additional Reference :
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.