[英]IOS Push notification for messaging app
I am working with a messaging app and the app needs to receive the notification from the server (chat message). 我正在使用消息传递应用程序,该应用程序需要从服务器接收通知(聊天消息)。 I am facing the problem when receiving the silent notification, most of the notification can't received by the device, the scenario as below:
我收到静默通知时遇到问题,设备无法接收大多数通知,情况如下:
iOS 10 – Bring the app into background and push the silent notification, all notification can receive by the device. iOS 10 –将应用程序置于后台并推送静默通知,设备可以接收所有通知。
iOS 11 – Bring the app into background and push the silent notification, device only can receive first 10 notifications and the rest of the notification disappear, I try to reboot the device and put the app into the background, able to receive another few notification and after that all not receive again. iOS 11 –将应用程序置于后台并推送静默通知,设备仅能接收前10条通知,其余通知消失,我尝试重新启动设备并将应用程序置于后台,能够接收到另外几条通知,在那之后所有都不会再收到。
Both iOS 10 and 11 – Kill the app and push the silent notification, all the notifications not receive. iOS 10和11 –杀死应用程序并推送静默通知,所有通知都不会收到。
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { logging(cls: self, mod: "APP", msg: "Did receive remote notification") }
I try the Whatsapp push notification, even I kill the app and turn off the background app refresh in setting, all the notification still come in, I'm curious how Whatsapp handle the push notification? 我尝试使用Whatsapp推送通知,即使我终止了该应用程序并在设置中关闭了后台应用程序刷新,所有通知仍会传入,我很好奇Whatsapp如何处理推送通知?
How do I solve this notification issue? 如何解决此通知问题?
Ideally you should use XMPP server base for live chat. 理想情况下,您应该使用XMPP服务器库进行实时聊天。
XMPP server has RTC ( Real time communication ) protocol, where 2 or more parties can connect, exchange document, live chat, video call, audio call etc. XMPP服务器具有RTC(实时通信)协议,其中2个或更多方可以连接,交换文档,实时聊天,视频通话,音频通话等。
You can also integrate websocket, for knowing user is online / office and other activities. 您还可以集成websocket,以了解用户在线/办公室等活动。
Integrating apple push, is not a 100% solution for live chat app like whatsapp, facebook messager, skype etc. 集成Apple Push,不是whatsapp,facebook messager,skype等实时聊天应用程序的100%解决方案。
From iOS 8, Apple introduced a new kind of push notification service called VoIP push. 从iOS 8开始,Apple推出了一种新的推送通知服务,称为VoIP推送。 VoIP push is provided by the Apple's PushKit framework.
VoIP推送由Apple的PushKit框架提供。
Normal push notification service has the following drawbacks , 普通的推送通知服务具有以下缺点 ,
Now coming to PushKit framework, 现在进入PushKit框架,
The benefits of PushKit framework are, PushKit框架的好处是,
So, for messaging apps like yours, the usage of PushKit framework is recommended. 因此,对于像您这样的消息传递应用程序,建议使用PushKit框架。 Here is a tutorial on Github which explains how to implement PushKit in your apps.
这是有关Github的教程 ,介绍了如何在应用中实现PushKit。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.