Ich versuche, Push-Benachrichtigungen mit Azure Notifications Hub in Xamarin Formen zu implementieren. Derzeit mache ich das für Android, mit GCM und ich folge this link. Aber in Schritt 5 des Tutorials in "Hinzufügen von Push-Benachrichtigungen zum Droid-Projekt" bekomme ich den Fehler modifier static is not valid for this item
. Nach diesem Schritt ist es das, was mein Code wie folgt aussieht:Modifikator statisch ist nicht gültig für diesen Artikel Fehler in C#
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;
}
}
}
Ich bin neu in C# und Xamarin Formen, und nicht heraus kann, wo ich falsch werde.
bitte lernen grundlegende C# -Syntax ... es scheint wie kompilieren Zeit Fehler (was bedeutet, dass Sie C# Grundlagen nicht wissen) und es genau sagt Ihnen, was ist falsch und in welcher Zeile ... – Selvin
Mögliche Duplikat von [Does C# unterstützt die Verwendung von statischen lokalen Variablen?] (Http://stackoverflow.com/questions/2393156/does-c-sharp-support-the-use-of-static-local-variables) – Selvin