I'm trying to Register push notificationninmy Xamarin Android project. I get a Bad Gateway exception in the Register func of the GCMService class. Specifically a 502 error as follows.
"502 - Web server received an invalid response while acting as a gateway or proxy server.There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server" This my Register function
public async void Register(Push push, IEnumerable<string> tags)
{
try
{
var templateBodyGCM = "{\"data\":{\"message\":\"$("+ RegistrationID+")\"}}";
JObject templates = new JObject();
templates["genericMessage"] = new JObject
{
{"body", templateBodyGCM}
};
await push.RegisterAsync(RegistrationID, templates);
Log.Info("Push Installation Id", push.InstallationId.ToString());
await Task.Run(async () => await RedCheetahApp.UpdateNotificationID(RegistrationID));
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
Debugger.Break();
}
}
I call it in the MainActivity UI thread. I have a Azure Cloud service which my Android App calls to register and get and get push notification. I've tried calling the API via PostMan but I get the same error i.e Bad Request.