I am trying to implement Push notifications using Azure's Notifications Hub in Xamarin forms. Currently I am doing this for Android, using GCM and I follow this link. But in Step 5 of the tutorial in 'Adding push notifications to the droid project', I get the error that modifier static is not valid for this item
. After this step, this is what my code looks like:
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create a new instance field for this activity.
static MainActivity instance = null;
// Set the current instance of MainActivity.
instance = this;
global::Xamarin.Forms.Forms.Init (this, bundle);
Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
LoadApplication (new App ());
try
{
// Check to ensure everything's setup right
GcmClient.CheckDevice(this);
GcmClient.CheckManifest(this);
// Register for push notifications
System.Diagnostics.Debug.WriteLine("Registering...");
GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
}
catch (Java.Net.MalformedURLException)
{
CreateAndShowDialog("There was an error creating the Mobile Service. Verify the URL", "Error");
}
catch (Exception e)
{
CreateAndShowDialog(e.Message, "Error");
}
private void CreateAndShowDialog(String message, String title)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetMessage(message);
builder.SetTitle(title);
builder.Create().Show();
}
// Return the current activity instance.
public static MainActivity CurrentActivity
{
get
{
return instance;
}
}
}
I am new to C# and Xamarin forms, and cannot figure out where I am going wrong.