使用推送通知在iOS中查看应用程序

时间:2022-09-10 20:20:47

I'm building a chatting application in iOS, I'm going to implement it using Node.js and Socket.IO for my backend.

我正在iOS中构建一个聊天应用程序,我将使用Node.js和Socket.IO为我的后端实现它。

I'm trying to implement push notification to notify the user of new message when they are not in the app.

我正在尝试实现推送通知,以便在用户不在应用程序中时通知用户新消息。

Do I send the notification for every message sent and ignore the push notification when inside the app or is there a way to only send the push notification when the user has exited the app?

我是否会针对发送的每条消息发送通知,并在应用内部时忽略推送通知,或者只有在用户退出应用时才发送推送通知?

1 个解决方案

#1


Since you using socket communicate server and client, so you can have a check mechanism.

由于您使用套接字通信服务器和客户端,因此您可以使用检查机制。

Client A send message to B.

客户端A向B发送消息

Sever received the message and check if B was online(connected to server): Yes: just send message using the socket B connected No: push notification to B

Sever收到消息并检查B是否在线(连接到服务器):是:只使用连接的套接字B发送消息否:将通知推送到B

#1


Since you using socket communicate server and client, so you can have a check mechanism.

由于您使用套接字通信服务器和客户端,因此您可以使用检查机制。

Client A send message to B.

客户端A向B发送消息

Sever received the message and check if B was online(connected to server): Yes: just send message using the socket B connected No: push notification to B

Sever收到消息并检查B是否在线(连接到服务器):是:只使用连接的套接字B发送消息否:将通知推送到B