Hi,
I posted this previously in the Android and Cross Platform forums but did not get any responses. Trying again here.
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. This is being called to register the user/device on Azure Notifications Hub.
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 can't rely on OnTokenRefresh() in the FirebaseInstanceIdService-derived class because I need the user to log in first.
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.