.NET MAUI Android App not registering for Push notifications

2 days ago 11
ARTICLE AD BOX

I am following the instructions found at https://learn.microsoft.com/en-us/dotnet/maui/data-cloud/push-notifications?view=net-maui-10.0 to set up an .Net MAUI Android application to receive push notifications. I believe I have followed all steps in the article to the letter (for all of the Android parts anyway, I've skipped IOS) however when I click the "Register" button on the demo app I receive an error message in the app as follows:

"One or more errors occurred. (Response status code does not indicate success: 422 (Unprocessable Entity).)"

If I trail the logs in the API app running in Azure I can see the corresponding error

2026-05-02 14:51:56.203 +00:00 [Trace] Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Executing action method PushNotificationsAPI.Controllers.NotificationsController.UpdateInstallation (PushNotificationsAPI) with arguments (PushNotificationsAPI.Models.DeviceInstallation)<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>IIS Detailed Error - 422.0 - Unprocessable Entity</title><style type="text/css"><!--body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;}code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;}.config_source code{font-size:.8em;color:#000000;}pre{margin:0;font-size:1.4em;word-wrap:break-word;}ul,ol{margin:10px 0 10px 5px;}ul.first,ol.first{margin-top:5px;}fieldset{padding:0 15px 10px 15px;word-break:break-all;}.summary-container fieldset{padding-bottom:5px;margin-top:4px;}legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;}legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px;font-weight:bold;font-size:1em;}a:link,a:visited{color:#007EFF;font-weight:bold;}a:hover{text-decoration:none;}h1{font-size:2.4em;margin:0;color:#FFF;}h2{font-size:1.7em;margin:0;color:#CC0000;}h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;}h4{font-size:1.2em;margin:10px 0 5px 0;}#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif;color:#FFF;background-color:#5C87B2;}#content{margin:0 0 0 2%;position:relative;}.summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}.content-container p{margin:0 0 10px 0;}#details-left{width:35%;float:left;margin-right:2%;}#details-right{width:63%;float:left;overflow:hidden;}#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF;background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal;font-size:1em;color:#FFF;text-align:right;}#server_version p{margin:5px 0;}table{margin:4px 0 4px 0;width:100%;border:none;}td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;}th{width:30%;text-align:right;padding-right:2%;font-weight:bold;}thead th{background-color:#ebebeb;width:25%;}#details-right th{width:20%;}table tr.alt td,table tr.alt th{}.highlight-code{color:#CC0000;font-weight:bold;font-style:italic;}.clear{clear:both;}.preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;}--></style></head><body><div id="content"><div class="content-container"><h3>HTTP Error 422.0 - Unprocessable Entity</h3><h4>The custom error module does not recognize this error.</h4></div><div class="content-container"><fieldset><h4>Most likely causes:</h4><ul> <li>A module set an infrequently used status code.</li> </ul></fieldset></div><div class="content-container"><fieldset><h4>Things you can try:</h4><li>Investigate why the module set the status code.</li></fieldset></div><div class="content-container"><fieldset><h4>Detailed Error Information:</h4><div id="details-left"><table border="0" cellpadding="0" cellspacing="0"><tr class="alt"><th>Module</th><td>   AspNetCoreModuleV2</td></tr><tr><th>Notification</th><td>   ExecuteRequestHandler</td></tr><tr class="alt"><th>Handler</th><td>   aspNetCore</td></tr><tr><th>Error Code</th><td>   0x00000000</td></tr></table></div><div id="details-right"><table border="0" cellpadding="0" cellspacing="0"><tr class="alt"><th>Requested URL</th><td>   https://push-test-notify:80/api/notifications/installations</td></tr><tr><th>Physical Path</th><td>   C:\home\site\wwwroot\api\notifications\installations</td></tr><tr class="alt"><th>Logon Method</th><td>   Anonymous</td></tr><tr><th>Logon User</th><td>   Anonymous</td></tr></table><div class="clear"></div></div></fieldset></div><div class="content-container"><fieldset><h4>More Information:</h4>Any module can call SetStatus with the status, substatus or HRESULT. The custom error module only displays status specific error messages for well known errors.<p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&IIS70Error=422,0,0x00000000,20348">View more information »</a></p><p>Microsoft Knowledge Base Articles:</p></fieldset></div></div></body></html>

When setting break points in the code I can see the 422 is being returned in this code block:

public async Task RegisterDeviceAsync(params string[] tags) { var deviceInstallation = DeviceInstallationService?.GetDeviceInstallation(tags); await SendAsync<DeviceInstallation>(HttpMethod.Put, RequestUrl, deviceInstallation) .ConfigureAwait(false); await SecureStorage.SetAsync(CachedDeviceTokenKey, deviceInstallation.PushChannel) .ConfigureAwait(false); await SecureStorage.SetAsync(CachedTagsKey, JsonSerializer.Serialize(tags)); }

with the following being the culprit:

var deviceInstallation = DeviceInstallationService?.GetDeviceInstallation(tags);

I've gone down a rabbit hole of Googling for a result and trying to use Github Copilot to try and resolve the error but I'm really unsure as to why I'm receiving the 422 error message.

FYI - not sure if its the cause or not but I am using an Android Emulator to test this app on.

Can anyone see what I'm doing wrong here?

Read Entire Article