I want to develop an multiuser IOS application with push notification , an every user will get different notifications which are related to his account. My question is that, is it possible to make differences when another user is logged in, can the previous user unsubscribe or unregister from receiving his notifications when logs out? Please provide me some examples. Thank you very much!
Asked
Active
Viewed 76 times
0
-
Did you read about Apple Push Notificaiton and how it works? By using UDID you can distinguish user and send notification from server – Manish Mahajan Jul 04 '18 at 05:32
1 Answers
0
I will be your server which will be configuring and sending payload to the APNS for push notification to be sent to the user device. Also before the app finishes launching for first time, it should be configured to register for push notification. After registering you will get the device token, which will be used to send notification to a particular device.
- Obtain the device token.
- Send the server, userid and device token when the user logs in.
- Send the server, device token and user id nil(you can use whatever you want as a contract between device end and server, to notify that no user is logged in on this device) when user logs out.
- Repeat step 2

Keshav Raj
- 376
- 1
- 7
-
Thank you. I have one more question. What will happen in that moment when the user wants to log out, and the application is offline? – Attila Jul 04 '18 at 06:35
-
Depends on the use case. If there is some sensitive info, then you don't allow user to logout until response from server comes. In other case you can allow user to log out and send this info when the internet comes back. Anyway in a multiuser app, login and logout will be server dependent bcz when a new user logs in, you have to fetch the relevant data from server and delete the old user's data. So internet connection will be mandatory for your use case(I think so..) – Keshav Raj Jul 04 '18 at 07:02
-
The notifications are sensitive. Can I disable receiving notifications locally when user logs out and there is no internet connection, and reenable receiving it when an another user logged in successfully? – Attila Jul 04 '18 at 07:18
-
I think you should read up on notifications as I am not sure they are the ideal solution for what you are proposing..... Firstly they won’t work if there is no internet connection. Secondly sensitive information should not be sent using notifications as there is no guarantee that the notification will be received. – Mark Jul 04 '18 at 11:51
-
@Mark As per Apple guidelines, you should never be sending the sensitive information in notification unless it is encrypted or doesn't make sense outside the app context. It was the most simple solution. Ideal solution will be using UserNotificationUI framework to process the info and show based on whether that particular user is logged in else just discard it. https://developer.apple.com/documentation/usernotificationsui/ – Keshav Raj Jul 04 '18 at 12:17