Dieser Code führt dazu, dass das Gerät eine Testbenachrichtigung erhält. Es wird jedoch kein Anruf an RegisterNativeAsync
gesendet, es sei denn, es liegt ein Fehler vor. Wie weiß also der Hub über das Gerät?Wie kann das Gerät Benachrichtigungen empfangen, obwohl SBNotificationHub.RegisterNativeAsync() nie aufgerufen wird?
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
SBNotificationHub Hub { get; set; }
public const string ConnectionString = "Endpoint=xxx";
public const string NotificationHubPath = "xxx";
public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
{
var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(uiApplication, launchOptions);
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
// Create a new notification hub with the connection string and hub path
Hub = new SBNotificationHub(ConnectionString, NotificationHubPath);
// Unregister any previous instances using the device token
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
}
});
});
}
}
_ "aber es gibt keinen Aufruf an' RegisterNativeAsync', außer es liegt ein Fehler vor. "_ - wirklich? Ich sehe genau das Gegenteil, es heißt, wenn _no_ error "UnregisterAllAsync" aufrufen würde. –
Ja, ich denke, Sie können einen Punkt haben. –
Obwohl noch keinen Breakpoint getroffen. –