0
このコードはデバイスにテスト通知を受信しますが、エラーがない限りRegisterNativeAsync
への呼び出しはありません。したがって、ハブはデバイスについてどのように知っていますか?SBNotificationHub.RegisterNativeAsync()は決して呼び出されないのに、デバイスは通知を受け取ることができますか?
[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
}
});
});
}
}
_ "エラーがない限り、' RegisterNativeAsync'は呼び出されません。 "私は 'UnregisterAllAsync'を呼び出す_no_エラーがあった場合、それとは逆のことをします。 –
はい、あなたはポイントがあると思います。 –
まだブレークポイントには達していませんが。 –