Open JoeTomkinson opened 3 years ago
Howdy - I've seen reports of similar issues. In those cases, the Xamarin.Android Release profile was using a code shrinker that was more (read: too) aggressive than the Debug profile. To see if this is your issue, you'll need to ensure that the proguard configuration file is setup to not strip out anything in the com.microsoft.windowsazure.messaging.notificationhubs namespace. Something like:
-keep class com.microsoft.windowsazure.messaging.notificationhubs.** { <init>(***); }
Howdy - I've seen reports of similar issues. In those cases, the Xamarin.Android Release profile was using a code shrinker that was more (read: too) aggressive than the Debug profile. To see if this is your issue, you'll need to ensure that the proguard configuration file is setup to not strip out anything in the com.microsoft.windowsazure.messaging.notificationhubs namespace. Something like:
-keep class com.microsoft.windowsazure.messaging.notificationhubs.** { <init>(***); }
Apologies for a slow reply. I'll look to try this today; as far as I was aware however I don't believe I had a code shrinker set on the release build. But it wouldn't surprise me if there was something strange going on under the hood of the release build so I'll investigate further and report back.
So I actually set the R8 shrinker to run as it was set to blank, that's produced the following error:
{
"JniPeerMembers": {
"ManagedPeerType": "WindowsAzure.Messaging.NotificationHubException, Xamarin.Azure.NotificationHubs.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"JniPeerTypeName": "com/microsoft/windowsazure/messaging/NotificationHubException",
"JniPeerType": {
"PeerReference": {
"Handle": {
"value": 17866
},
"Type": 2,
"IsValid": true
},
"Name": "com/microsoft/windowsazure/messaging/NotificationHubException"
},
"InstanceMethods": {},
"InstanceFields": {},
"StaticMethods": {},
"StaticFields": {}
},
"StatusCode": 400,
"StackTrace": " at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <3f19c9fc57a34ac9a473579164f8755e>:0 \n at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <3f19c9fc57a34ac9a473579164f8755e>:0 \n at WindowsAzure.Messaging.NotificationHub.Register (System.String pnsHandle, System.String[] tags) [0x00043] in <254d369ec5544bb1b606035994077f91>:0 \n at NorthNorfolk.Mobile.Client.Droid.Notifications.FirebaseService.SendRegistrationToServer (System.String token) [0x00078] in <4b8b745c15df475a92a1855a0ba61d95>:0 \n --- End of managed WindowsAzure.Messaging.NotificationHubException stack trace ---\ncom.microsoft.windowsazure.messaging.NotificationHubException\n\tat com.microsoft.windowsazure.messaging.Connection.executeRequest(Unknown Source:146)\n\tat com.microsoft.windowsazure.messaging.Connection.executeRequest(Unknown Source:134)\n\tat com.microsoft.windowsazure.messaging.Connection.executeRequest(Unknown Source:7)\n\tat com.microsoft.windowsazure.messaging.NotificationHub.upsertRegistrationInternal(Unknown Source:22)\n\tat com.microsoft.windowsazure.messaging.NotificationHub.registerInternal(Unknown Source:48)\n\tat com.microsoft.windowsazure.messaging.NotificationHub.register(Unknown Source:27)\n\tat crc64d75b20eac0c397e9.FirebaseService.n_onNewToken(Native Method)\n\tat crc64d75b20eac0c397e9.FirebaseService.onNewToken(Unknown Source:0)\n\tat com.google.firebase.messaging.FirebaseMessagingService.handleIntent(Unknown Source:53)\n\tat com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(Unknown Source:1)\n\tat com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)\n\tat com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)\n\tat java.lang.Thread.run(Thread.java:764)\n",
"JniIdentityHashCode": 196544507,
"PeerReference": {
"Handle": {
"value": 18122
},
"Type": 2,
"IsValid": true
},
"Handle": {
"value": 18122
},
"Cause": null,
"Message": null,
"Data": {},
"InnerException": null,
"Source": "mscorlib",
"HResult": -2146233088
}
I can see that there's a reference to a status code this time and a 400 error. Any thoughts on what could be causing that because as far as I know this is all set up exactly as it should be based on the Microsoft documentation.
Also not sure if it's relevant but while looking at logcat I get the following warning just after the above error:
A connection to https://[Our Azure Notification Hub name].servicebus.windows.net/ was leaked. Did you forget to close a response body?
Describe the bug In a Xamarin Forms project implementing the Azure Notification Hub throws an exception in release mode that it does not exhibit during debugging that causes remote PNS registrations to fail.
Exception or Stack Trace
To Reproduce
Simply run the example project for Xamarin Forms focusing on the android platform, switch to release mode and look out for the errors in the logcat.
Code Snippet
FireBaseService in the Android Native project:
Android Manifest:
Expected behavior
I would expect this to register the device with the notification hub and be visible as a registration in Service Bus Explorer.
Setup (please complete the following information):