iOS 即时通讯服务 : Best way to to check for new messages?

标签 ios xcode web-services instant-messaging

如果我要为 iOS 制作一个即时通讯工具,我将如何检查新消息?

是否需要持续检查网络服务以查看是否有任何新消息(例如每隔几秒),或者使用网络服务进行某种实时提要以立即更新应用程序?

最佳答案

您可以使用 NSStreamCSStream 从您的 iOS 应用程序与 TCP 服务器进行通信。与您的服务器保持开放的套接字连接将允许服务器立即向您发送有关新消息的通知。您将需要一个输出流 (NSOutputStream) 和一个输入流 (NSInputStream),以便您可以轻松并行地管理传出和传入通信。

一些有用的链接:

Introduction to Stream Programming Guide for Cocoa

How To Create A Socket Based iPhone App and Server

Tutorial: Building A Simple iOS TCP Socket Based App Client And Server

关于iOS 即时通讯服务 : Best way to to check for new messages?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22105026/

相关文章:

ios - FlashBuilder、Adobe AIR 和 iOS 开发出现 PackageInspectionFailed 错误

xcode - Double 无法转换为 UInt8,Swift 错误

ios - 未调用准备函数 - swift 3

.net - Microsoft mocks 和 mocking out SqlConnection 用于集成测试

web-services - 具有 "No such operation: HTTP GET PATH_INFO"的网络服务

linux - 如何使用 CURL 命令使用 web 服务?

ios - 仅在 iOS 11 可用时导入模块

ios - ENABLE_BITCODE 在 xcode 7 中做了什么?

ios - 从用户位置查找数组中最接近的经度和纬度,并根据从一个纬度到另一个纬度的最短距离对数组进行排序

ios - 使用self调用方法会导致错误