我尝试过Android和Windows推送通知,一切正常。但是,在iOS方面,出了点问题。
我正在尝试使用这些教程
向我的Xamarin.iOS应用添加推送通知从Azure测试发送我收到“消息已成功发送,但没有匹配的目标。”
我按照原样遵循了所有步骤但是当我设置断点时,我总是得到“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;
}
}
我的问题是;
注意:我正在使用