简体   繁体   中英

ios 13 push-notification gets cleared as soon as we get when device is locked

when I'm receiving push notification on iOS 13, and device is locked. I' getting pushnotifcation, but it gets cleared immediately without any user interaction.

I'm using .net and following is payload code which I'm using

{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 

This can happen if you have a code that decreases the app icon's notification badge number. If you do that, make sure you do it only if the application is active. If it is inactive and you decrease the badge number, it might cause the notification to appear and immediately disappear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM