iOS远程通知在后台模式下不会触发

iOS远程通知在后台模式下不会触发,ios,iphone,azure,xamarin,push-notification,Ios,Iphone,Azure,Xamarin,Push Notification,我通常不在这里发帖,但这次我被卡住了。我已经在这个论坛、stackoverflow和google上搜索过了,但我不明白我做错了什么 我正在开发一个Xamarin.Forms应用程序,当收到远程通知时,我很难启动这些方法。 这是我的密码: 登录后,我立即执行此方法注册到apple notification center: public void RegisterForNotifications () { var settings = UIUserNotificationSettin

我通常不在这里发帖,但这次我被卡住了。我已经在这个论坛、stackoverflow和google上搜索过了,但我不明白我做错了什么

我正在开发一个Xamarin.Forms应用程序,当收到远程通知时,我很难启动这些方法。 这是我的密码:

登录后,我立即执行此方法注册到apple notification center:

public void RegisterForNotifications ()
{
        var settings = UIUserNotificationSettings.GetSettingsForTypes(
            UIUserNotificationType.Alert
            | UIUserNotificationType.Badge
            | UIUserNotificationType.Sound,
            new NSSet());
        UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
        UIApplication.SharedApplication.RegisterForRemoteNotifications();
}
此调用成功触发AppDelegate上的此方法

public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
    var azureService = App.GetBackEndService ();
    azureService.RegisterForNotifications (deviceToken);
}
RegisterForNotifications在azure通知中心注册:

public static async void RegisterForNotifications(this BackEndService service, NSData deviceId)
{
            Microsoft.WindowsAzure.MobileServices.MobileServiceClient client = new Microsoft.WindowsAzure.MobileServices.MobileServiceClient (service.Client.ApplicationUri);
            client.CurrentUser = service.Client.CurrentUser;
            var push = client.GetPush ();
            var tags = new List<string>() { App.GetBackEndService().Client.CurrentUser.UserId };
            try{
                await push.UnregisterAllAsync(deviceId);
            }catch(Exception e){
                var exp = e.Message;
            }
            await push.RegisterTemplateAsync(deviceId, NOTIFICATION_TEMPLATE, "", "NotificationTemplate", tags);
}
但在后台模式下(例如,当我按下Iphone上的Home按钮时),不会触发任何内容 在通常显示iOS通知的上方栏上没有显示任何内容。 我在ReceivedRemoteNotification、DidReceiveRemoteNotification和FinishedLaunching中设置了一个断点

我在Info.plist中的启用后台模式下正确设置了远程通知


有人能理解我错过了什么吗

假设您已经实现了“UIKit.uiapplicationedegate.didReceivereMotentification”(使用
应用程序:didReceivereMotentification:fetchCompletionHandler:
选择器),那么您的通知是否包含有效负载(甚至是伪的),即
可用内容=1
是,我确实实现了“didReceivereMotentification”但它永远不会被触发(前台和后台)。我的通知确实带有一个有效负载,我可以从“ReceivedRemoteNotification”=>NSDictionary UserInfo中检索到它。我将更新它。我成功地点击了“ReceivedRemoteNotification”(在后台模式下)仅从azure移动服务>通知中心>调试并发送此paylod:{“aps”:{“内容可用”:1,“声音”:“}}现在我的问题是,是否可以使用模板从.NET后端实现此目的?看起来我做错了什么
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
{
    ShowAlerts (userInfo);
}