%3CLINGO-SUB%20id%3D%22lingo-sub-2158140%22%20slang%3D%22en-US%22%3EHow%20to%20use%20REST%20API%20to%20send%20notifications%20to%20Baidu%20device%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2158140%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20will%20introduce%20how%20to%20use%20Azure%20Notification%20Hub%20REST%20API%20to%20send%20a%20notification%20to%20device%20with%20Baidu%20Push.%20It%20provides%20an%20example%20of%20how%20to%20retrieve%20the%20PNS%20handle%20and%20send%20notification%20to%20device%20using%20REST%20API%20with%20Baidu%20Push.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22yawhu_0-1614060573245.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256912iD4CE45D913F30C0F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22yawhu_0-1614060573245.png%22%20alt%3D%22yawhu_0-1614060573245.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EPre-requirement%20%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EBefore%20starting%2C%20you%20must%20setup%20a%20Baidu%20Push%20environment%20and%20create%20a%20application%20in%20Android%20Studio.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EDownload%20%3CA%20href%3D%22https%3A%2F%2Fpush.baidu.com%2Fsdk%2Fpush_client_sdk_for_android%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EBaidu%20Push%20Android%20SDK%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20Baidu%20Push%20account%20and%20create%20application%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fpush.baidu.com%2Fdoc%2Fguide%2Fjoin%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGetting%20Started%20with%20Baidu%20Push%20(baidu.com)%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ECreate%20an%20application%20in%20Android%20Studio%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fnotification-hubs%2Fnotification-hubs-baidu-china-android-notifications-get-started%23connect-your-app-to-the-notification-hub%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EConnect%20your%20app%20to%20the%20notification%20hub%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGetting%20started%20with%20Azure%20Notification%20Hub%20using%20Baidu%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EEnter%20%3CSTRONG%3EAPI%20Key%3C%2FSTRONG%3E%20and%20%3CSTRONG%3ESECRET%20KEY%3C%2FSTRONG%3E%20in%20%3CSTRONG%3EAzure%20Portal%3C%2FSTRONG%3E%20-%26gt%3B%20%3CSTRONG%3ENotification%20Hub%3C%2FSTRONG%3E%20-%26gt%3B%20%3CSTRONG%3EBaidu%20(Android%20China)%3C%2FSTRONG%3E.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22yawhu_1-1614060573255.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256914i615561684E58C632%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22yawhu_1-1614060573255.png%22%20alt%3D%22yawhu_1-1614060573255.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3ENote%20%3A%20Go%20to%20the%20%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3EConfiguration%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%20page%20of%20the%20Baidu%20Push%20application%20and%20you%20can%20find%20%3C%2FSPAN%3E%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3EAPI%20KEY%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%20and%20%3C%2FSPAN%3E%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3ESECRET%20KEY%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E.%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22yawhu_2-1614060573262.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256913i757952FFD35983F8%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22yawhu_2-1614060573262.png%22%20alt%3D%22yawhu_2-1614060573262.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3EExecute%20your%20application%20in%20Android%20Studio%20and%20you%20should%20see%20below%20keywords%20in%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22yawhu_3-1614060573263.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256915iDEC4799727C4CA7B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22yawhu_3-1614060573263.png%22%20alt%3D%22yawhu_3-1614060573263.png%22%20%2F%3E%3C%2FSPAN%3E.%3CBR%20%2F%3EerrorCode%3D0%20%3A%200%20means%20the%20device%20is%20registered%20successfully%20via%20Baidu%20SDK.%3CBR%20%2F%3EuserId%20%3A%20copy%20this%20for%20next%20step%3CBR%20%2F%3EchannelId%3A%20copy%20this%20for%20next%20step%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22yawhu_4-1614060573312.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256917iBCC749C3FFF9FF30%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22yawhu_4-1614060573312.png%22%20alt%3D%22yawhu_4-1614060573312.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20registration%20for%20the%20device.%20This%20method%20generates%20a%20registration%20ID%2C%20which%20you%20can%20subsequently%20use%20to%20retrieve%2C%20update%2C%20and%20delete%20this%20registration.%3CBR%20%2F%3E%3CSTRONG%3E-%20Request%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CTABLE%20border%3D%221%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2249.926578560939795%25%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3EMethod%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2249.926578560939795%25%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3ERequest%20URI%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2249.926578560939795%25%22%3E%3CP%3EPOST%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2249.926578560939795%25%22%3E%3CP%20data-unlink%3D%22true%22%3Ehttps%3A%2F%2F%3CNOTIFICATION_HUB_NAMESPACE%3E.servicebus.windows.net%2F%3CNOTIFICATION_HUB_NAME%3E%2Fregistrations%2F%3Fapi-version%3D2015-01%26nbsp%3B%3C%2FNOTIFICATION_HUB_NAME%3E%3C%2FNOTIFICATION_HUB_NAMESPACE%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%3CSTRONG%3E%3CBR%20%2F%3E-%20Request%20Headers%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CTABLE%20width%3D%22530px%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22141.111px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3ERequest%20Header%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22387.778px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22141.111px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3EContent-Type%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22387.778px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3Eapplication%2Fatom%2Bxml%3Btype%3Dentry%3Bcharset%3Dutf-8%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22141.111px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3EAuthorization%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22387.778px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fservice-bus-messaging%2Fservice-bus-sas%23generate-a-shared-access-signature-token%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Service%20Bus%20access%20control%20with%20Shared%20Access%20Signatures%20-%20Azure%20Service%20Bus%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22141.111px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3Ex-ms-version%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22387.778px%22%20style%3D%22line-height%3A%201.71429%3B%22%3E%3CP%20style%3D%22line-height%3A%201.71429%3B%22%3E2015-01%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%3CSTRONG%3E%3CSTRONG%3E%3CBR%20%2F%3E-%20Request%20Body%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FSTRONG%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3EXML%3C%2FFONT%3E%3CSTRONG%3E%3CSTRONG%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FSTRONG%3E%3CPRE%20class%3D%22lia-code-sample%20language-basic%22%3E%3CCODE%3E%0A%3CENTRY%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CCONTENT%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CBAIDUREGISTRATIONDESCRIPTION%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CBAIDUUSERID%3E%7BuserId%7D%3C%2FBAIDUUSERID%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CBAIDUCHANNELID%3E%7BchannelId%7D%3C%2FBAIDUCHANNELID%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FBAIDUREGISTRATIONDESCRIPTION%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FCONTENT%3E%0A%3C%2FENTRY%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CSTRONG%3E-%20Response%20Code%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2274.4444px%22%20height%3D%2227px%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3ECode%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22645.556px%22%20height%3D%2227px%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2274.4444px%22%20height%3D%2227px%22%3E%3CP%3E200%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22645.556px%22%20height%3D%2227px%22%3E%3CP%3ERegistration%20created%20successfully.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%3CBR%20%2F%3E%3CSTRONG%3E-%26nbsp%3BResponse%20Body%3C%2FSTRONG%3E%3CBR%20%2F%3EUpon%20success%2C%20a%20validated%20Atom%20entry%20is%20returned.%20It%20includes%20read-only%20elements%20such%20as%20ETag%2C%20RegistrationId%2C%20and%20ExpirationTime.%20For%20example%3A%3CBR%20%2F%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3EXML%3C%2FFONT%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-basic%22%3E%3CCODE%3E%3CENTRY%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CID%3Ehttps%3A%2F%2Fnotificationhubn.servicebus.windows.net%2Fnotificationhub1%2Fregistrations%2F%7BregisterId%7D%3Fapi-version%3D2015-01%3C%2FID%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CTITLE%3E%7BregisterId%7D%3C%2FTITLE%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CPUBLISHED%3E2021-02-19T06%3A52%3A22Z%3C%2FPUBLISHED%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CUPDATED%3E2021-02-19T06%3A52%3A22Z%3C%2FUPDATED%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CLINK%20%2F%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CCONTENT%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CBAIDUREGISTRATIONDESCRIPTION%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CETAG%3E1%3C%2FETAG%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CEXPIRATIONTIME%3E9999-12-31T23%3A59%3A59.999%3C%2FEXPIRATIONTIME%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CREGISTRATIONID%3E%7BregisterId%7D%3C%2FREGISTRATIONID%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CBAIDUUSERID%3E%7BuserId%7D%3C%2FBAIDUUSERID%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CBAIDUCHANNELID%3E%7BchannelId%7D%3C%2FBAIDUCHANNELID%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FBAIDUREGISTRATIONDESCRIPTION%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FCONTENT%3E%0A%3C%2FENTRY%3E%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3CLI%3EUse%20%3CSTRONG%3ETest%20Send%3C%2FSTRONG%3E%20to%20check%20whether%20the%20device%20is%20registered%20successfully%20in%20the%20previous%20step.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22yawhu_5-1614060573322.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256916i427C95A987F2742B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22yawhu_5-1614060573322.png%22%20alt%3D%22yawhu_5-1614060573322.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3ESends%20a%20Baidu%20native%20notification%20through%20a%20notification%20hub.%3CBR%20%2F%3E%3CSTRONG%3E-%20Request%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CTABLE%20width%3D%22821px%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2271.1111px%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3EMethod%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22747.778px%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3ERequest%20URI%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2271.1111px%22%3E%3CP%3EPOST%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22747.778px%22%3E%3CP%20data-unlink%3D%22true%22%3Ehttps%3A%2F%2F%3CNOTIFICATION_HUB_NAMESPACE%3E.servicebus.windows.net%2F%3CNOTIFICATION_HUB_NAME%3E%2Fmessages%2F%3Fapi-version%3D2015-04%26nbsp%3B%3C%2FNOTIFICATION_HUB_NAME%3E%3C%2FNOTIFICATION_HUB_NAMESPACE%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%3CBR%20%2F%3E%3CSTRONG%3E-%20Request%20Headers%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CTABLE%20width%3D%22685px%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22293.333px%22%20height%3D%2227px%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3ERequest%20Header%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22390px%22%20height%3D%2227px%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22293.333px%22%20height%3D%2227px%22%3E%3CP%3EContent-Type%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22390px%22%20height%3D%2227px%22%3E%3CP%3Eapplication%2Fjson%3Bcharset%3Dutf-8%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22293.333px%22%20height%3D%2254px%22%3E%3CP%3EAuthorization%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22390px%22%20height%3D%2254px%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fservice-bus-messaging%2Fservice-bus-sas%23generate-a-shared-access-signature-token%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Service%20Bus%20access%20control%20with%20Shared%20Access%20Signatures%20-%20Azure%20Service%20Bus%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22293.333px%22%20height%3D%2227px%22%3E%3CP%3EServiceBusNotification-DeviceHandle%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22390px%22%20height%3D%2227px%22%3E%3CP%3E%7BRegistrationId%7D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22293.333px%22%20height%3D%2227px%22%3E%3CP%3EServiceBusNotification-Format%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22390px%22%20height%3D%2227px%22%3E%3CP%3Ebaidu%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22293.333px%22%20height%3D%2227px%22%3E%3CP%3Ex-ms-version%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22390px%22%20height%3D%2227px%22%3E%3CP%3E2015-04%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%3CBR%20%2F%3E%3CSTRONG%3E-%20Request%20Body%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3EJSON%3C%2FFONT%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%22title%22%3A%22Title%22%2C%22description%22%3A%22Notification%26nbsp%3BHub%26nbsp%3Btest%26nbsp%3Bnotification%22%7D%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CBR%20%2F%3E%3CSTRONG%3E-%20Response%20Code%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2284%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3ECode%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22814%22%3E%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2284%22%3E%3CP%3E201%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22814%22%3E%3CP%3EMessage%20successfully%20send%20to%20Baidu.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3C%2FLI%3E%0A%3CLI%3EYour%20device%20should%20receive%20the%20notification%20you%20send%20in%20previous%20step%20in%20few%20seconds.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAdditional%20Reference%20%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fnotificationhubs%2Fcreate-registration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECreate%20a%20registration%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fnotificationhubs%2Fdirect-send%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDirect%20send%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2158140%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20will%20introduce%20how%20to%20use%20Azure%20Notification%20Hub%20REST%20API%20to%20send%20notifications%20to%20Baidu%20device.%20It%20provides%20an%20example%20of%20how%20to%20retrieve%20the%20PNS%20handle%20and%20send%20notification%20to%20device%20using%20REST%20API%20with%20Baidu%20Push.%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

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.

yawhu_0-1614060573245.png

 

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

  1. Enter API Key and SECRET KEY in Azure Portal -> Notification Hub -> Baidu (Android China).
    yawhu_1-1614060573255.png
    Note : Go to the Configuration page of the Baidu Push application and you can find API KEY and SECRET KEY.
    yawhu_2-1614060573262.png
  2. Execute your application in Android Studio and you should see below keywords inyawhu_3-1614060573263.png.
    errorCode=0 : 0 means the device is registered successfully via Baidu SDK.
    userId : copy this for next step
    channelId: copy this for next step
    yawhu_4-1614060573312.png
  3. Create a registration for the device. This method generates a registration ID, which you can subsequently use to retrieve, update, and delete this registration.
    - Request

    Method

    Request URI

    POST

    https://<notification_hub_namespace>.servicebus.windows.net/<notification_hub_name>/registrations/?api-version=2015-01 


    - Request Headers

    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


    - Request Body
    XML
    <?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>

    - Response Code

    Code

    Description

    200

    Registration created successfully.


    - Response Body
    Upon success, a validated Atom entry is returned. It includes read-only elements such as ETag, RegistrationId, and ExpirationTime. For example:
    XML
    <entry a:etag="W/&quot;1&quot;" 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>​
  4. Use Test Send to check whether the device is registered successfully in the previous step.
    yawhu_5-1614060573322.png
  5. Sends a Baidu native notification through a notification hub.
    - Request

    Method

    Request URI

    POST

    https://<notification_hub_namespace>.servicebus.windows.net/<notification_hub_name>/messages/?api-version=2015-04 


    - Request Headers

    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


    - Request Body
    JSON
    {"title":"Title","description":"Notification Hub test notification"}​


    - Response Code

    Code

    Description

    201

    Message successfully send to Baidu.

  6. Your device should receive the notification you send in previous step in few seconds.

 

Additional Reference :