0
votes

I have chat App with push notification to inform the user he had a new message.

There are two sides using the app: client + Manager

I used PubNub to achieve chat goal, so the both are listing on the same channel: chat_channel

the problem is when I send Push Notification via Pubnub to inform the client for example that you have a new message from the manager,

In this case, the sender (i.e Manger) receive a push notification on his message because he is listening on the same channel! and that's wrong in logic.

Is there a solution to prevent this case without creating two channel (manager_channel, client_channel) for push notification?

I will be pleased for any help.

Thanks.

1

1 Answers

0
votes

Any device listening to a channel will receive a push notification. Even I had the same problem, so handled this Pubnub notification depending on the Application state: active and inactive.

In Active state, Applegate's didReceiveRemoteNotification method receive the message which sender [in your example case:Manager] pushes on a particular channel. Here, you can check sender of the message by adding flag isManager: YES parameter in notification payload and ignore them. I used it as acknowledge of a message delivered on the server.

While in Inactive state, the payload will be always from opposite side, pretty straight forward.

Just tried to help you!