0

Ich habe versucht Android und Windows Push-Benachrichtigungen und alles funktioniert gut. Auf der iOS-Seite stimmt etwas nicht.Push-Benachrichtigungen von Azure Notification Hub (Xamarin.iOS)

Ich versuche, Push-Benachrichtigungen an meine Xamarin.iOS App diese Tutorials

Von Azure-Test hinzufügen Senden bekam ich „Nachricht erfolgreich gesendet wurde, aber Es gab keine passenden Ziele. "

Ich habe gefolgt, alle Schritte, wie es ist, aber wenn ich einen Haltepunkt setzen, habe ich immer "isRegistered = false":

AppDelegate.cs

private SBNotificationHub Hub { get; set; } 
    public const string ConnectionString = "Endpoint=sb://..."; 
    public const string NotificationHubPath = "NotificationHubName..."; 


    public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) 
      { 
       // Set our preferred notification settings for the app 
       var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
        UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, 
        new NSSet()); 

       // Register for notifications 
       UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); 
       UIApplication.SharedApplication.RegisterForRemoteNotifications(); 
       bool IsRegistered = UIApplication.SharedApplication.IsRegisteredForRemoteNotifications; 

       return true; 
      } 
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) 
     { 
      Hub = new SBNotificationHub(ConnectionString, NotificationHubPath); 
      Hub.UnregisterAllAsync(deviceToken, (error) => 
      { 
       if (error != null) 
       { 
        // Error unregistering 
        return; 
       } 
       // Register this device with the notification hub 
       Hub.RegisterNativeAsync(deviceToken, null, (registerError) => 
       { 
        if (registerError != null) 
        { 
         // Error registering 
        } 
       }); 
      }); 
     } 

     public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo) 
     { 
      if (null != userInfo && userInfo.ContainsKey(new NSString("aps"))) 
      { 
       // Get the aps dictionary from the alert payload 
       NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; 
      } 
     } 

Meine Fragen sind;

  1. Warum melde ich mich nicht an?
  2. Wie kann ich erfahren, warum ich mich nicht registriere?
  3. Unterstützt Xamarin iOS 11.0 Push-Benachrichtigungen von Azure Notification Hub?

Hinweis: Ich verwende

  • Visual Studio 2017 (Version 15.4.0) unter Windows 10
  • Mac OS Hoch Siera Version 10.13
  • Xcode Version 9.0.1
  • VS für Mac Community Version 7.2 (Build 636)
  • Testen auf iPhone 5S, iPhone 6, iPhone 6S, iPhone 7, iPhone 8 - iOS11.0
+0

Zeigen Sie den Code in der 'RegisteredForRemoteNotifications' Methode. Registrierst du dich dort beim Notification Hub? –

+0

Ich habe die Methode "RegisteredForRemoteNotifications" zur Frage hinzugefügt. – aliyasar

+0

Haben Sie Haltepunkte verwendet, um zu sehen, was die Ergebnisse sind? Es besteht die Möglichkeit, dass die Registrierung bei Azure nie erfolgt. Aber nichts ist mit den Fehlern gemacht, so dass Sie nicht wissen würden –

Antwort

0

Gelöst wurde es mit einem physischen iPhone-Gerät.

"Der Simulator funktioniert nicht. Push Notifications. Und um von einem Server zu pushen, müssen Sie Geräte haben, auf die Sie ebenso wie Ihre App auf diesem Gerät drücken können."


"Das iPhone Simulator ist nicht in der Lage Push-Benachrichtigungen zu erhalten oder für sie erfolgreich zu registrieren."

enter image description here

Verwandte Themen