ios 13推送通知将在设备锁定时立即清除

问题描述 投票:0回答:1

当我在iOS 13上收到推送通知,并且设备被锁定时。我正在获取pushnotifcation,但无需任何用户交互即可立即清除它。

我正在使用.net,以下是我正在使用的有效负载代码

{to = notification.DeviceToken,
                    priority = "high",                    
                    content_available = true,
                    notification = new
                    {
                        body = notification.Message, //This will be a subtitle..
                        title = notification.Name, //This will be a title..
                    },
                    data = new
                    {
                        notificationId = notification.NotificationId,
                        userId = notification.UserId,
                        encryptedNotification = Crypto.Encrypt("id", notification.NotificationId.ToString())
                    }
                };
                string postbody = JsonConvert.SerializeObject(payload).ToString();
                Byte[] byteArray = Encoding.UTF8.GetBytes(postbody);

                tRequest.ContentLength = byteArray.Length;

                **tRequest.Headers.Add("apns-push-type", "alert");**
                **tRequest.Headers.Add("apns-priority", "5");**
}```

Please guide me what wrong in code. 

have referred following azure code to implement, but not able to find the cause.

https://docs.microsoft.com/en-us/azure/notification-hubs/push-notification-updates-ios-13 
ios push-notification ios13
1个回答
2
投票

如果您使用的代码会减少应用程序图标的通知徽章编号,则会发生这种情况。如果这样做,请确保仅在应用程序处于活动状态时才这样做。如果该按钮处于非活动状态,并且您减少了徽章编号,则可能会导致该通知出现并立即消失。

© www.soinside.com 2019 - 2024. All rights reserved.