I have a Xamarin for Visual Studio cross platform project and am getting an error trying to get notifications working using Azure Notifications Hub in the Android project. In the FirebaseInstanceIdService-derived class, I get an error when I try to instantiate a NotificationHub object.
NotificationHub hub = new NotificationHub(Constants.NotificationHubName, Constants.ListenConnectionString, this);
I usually get this error:
Unhandled Exception: Java.Lang.NullPointerException: occurred
But have also received:
Unhandled Exception: Java.Lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference occurred
I am calling this from a DependencyService that is invoked in the OnAppearing event of the Main Page.
I confirmed that the hub name and connection string are correct. And the context-related error certainly makes it seem related to "this." But I'm not sure what the issue is since this is how it is handled in all the sample code I've seen.
Any suggestions would be greatly appreciated.