When I say notifications, I mean custom app notifications, so not iOS notifications. Notifications like Facebook's notification tab. Basically I want to check if a user has new friend requests, or if someone has commented on their posts, then load this data into a TableView which is displayed in my Notifications tab.
I wondering how I go about continually checking for these notifications from my server. Obviously I shouldn't check on a single tab bar's view controller, such as the NotificationsViewController. So I'm thinking should this type of functionality be performed in the AppDelegate?
And how do I seamlessly perform a request in the background, then have my Notifications tab catch the response, and parse it, so I can display a notifications badge. A snippet of Swift code, and where I should be placing it would be really helpful!
Thank you.
You can use silent push notification, it will inform your app that something new happened without showing the alert to user (send it from your server), perform repeated request in background is very energy consuming and does not advised, also it wont work if your app is not openning. To store it then can just use NSUserDefault or CoreData
Related
I'm trying to make an App that's exactly like WhatsApp, so far the biggest limitation is that when a user re-opens the App after a while, and goes to a Conversation View, new Messages that were sent during the time the App was in Background/Suspended or Terminated states have to be recovered from a Server (API), and this causes a potential delay for new messages showing up in the Conversation View.
How can I achieve permanent Sync of an App with a server API? I'm kind of sure apps like WhatsApp manage to do this, because Messages never appear to be downloaded whenever you re-open the App after a while, right?
What is the right way to sort of Mimic this type of behavior? I really want to learn how to perform this kind of "advanced" synching and I don't know where to get started. Again, my goal is to try to avoid server-downloads of new Messages when a user re-enters a Conversation Viewfor example (because that would be bad UX)
Thanks in advance!
Your app will need push notifications. This is a must have for apps like this.
On the server, when you know that there are new messages, send a push notification to the app. This will let the app know that there are messages to read. At this point the app can badge the app icon, pop an alert and show on the notification screen. The user controls how notifications appear.
Details about notifications here:
https://developer.apple.com/notifications/
Your app can load all messages when it gets the notification.
iOS apps do have some limited options for background processes: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
The problem is that I want to make ios client responsible for taking care of displaying/not displaying push notification relating on some kind type in push dictionary.
I would present some kind of modal view where user can choose what notifications he want to see.
And the question is it possible to ignore that chosen type when app is turned off or in background?
I know it's bad solution due to unnecessary unwanted pushes to be send and drain battery and it surely should be managed on the server side, but for now I need very fast solution that would be replaced in the future or even there could be double side check.
No this is not possible, the push notification is handled by the system and not you app.
You only option is to use the background refresh with an background fetch push notification. This way you can handle the push notification in the background, and use UILocalNotification to push a notification in the notification center.
This a has draw back when some one has turned off the background update for your app.
The best way is to do it server side, just push the settings to you server and make the decision whether or not to send push notification bast on these settings.
I am creating an IOS application that makes use of PUSH notifications. When I send a PN, I send data to my application. IF my app is not active, I can then click the notification in the notification center to update the data in the app. However, IF I do not click the notification and I just resume the app via the launch screen, the app does not update correctly. Is there a way to update the apps pending notifications even if I don't press the notification center button and I just resume the app from the launch icon?
I have been scouring the internet with no luck. I have also tried to put the notification in a NSMUtable Array in the application delegate with no luck.
thank you in advance.
Without you having a list of notifications that the app can download from the server you won't have a consistent solution so that is the best bet.
If you turned on background fetch for your notifications then the app could maintain a list of the received notifications, but this approach would fail for any notifications coming in after the user had force quit the app.
I would like to know whether there is an alternative different than what I am thinking so far. I have an ios app, which gets data from my server, when the user clicks refresh button or so.
Now, I want to send data from server to the app - for example when an event started so as to update the label on that event.
I have thought of the following :
Use background fetch from my IOS app and connect to the server every an interval
Send a push notification and make the user open the app, and the app calls refresh
Is there any other way? Is it possible that server will send the data (just like a push notification) but without the notification to be visible, without firing the app, I just want to change some of its data - an approach similar to the Google Cloud Messaging for Android.
To visualise what I am saying, if you have used LiveScores app, it updates for example the minute of a live match - I want something similar.
I guess I need to follow approach 1, with background fetch (which became more effective in ios7) but just out of curiosity if there is any other solution out there.
Thanks
Under ios7+ you can do silent pushes (which aren't displayed) [see a nice tutorial — hayageek.com: iOS Silent Push notifications]
Under ios6 and below you are of of luck
Currently I am implementing an ios app with the server push notification.
I am successfully able to send push notifications with badge.
Badge count will be incremented from the server. If user opens the application from notification, it will reset count on the server.
Now the query is if user is not opening application from notification and deleting/clearing all notifications.
That means there will be no notification so when app will be opened from the background it wont find any notification and so it will not reset the count on server and also not the badge value on app icon.
So how can i resolve this issue?
Use custom notification icon and maintain read and unread counts with in the app,you will not manage badge counts from push notifications when user remove and open notifications in the app.
From what I understand, the only way your app is getting the relevant data is if the user clicks on the notification. I'm assuming you're sending a custom payload of some kind. Though I don't know the nature of your app at all, I would say this is really not the way to go specifically because of the problem you're encountering - you have no way of knowing if/when the user clears notifications in the Notification Center and if they do, that data is forever lost to your app.
I would recommend your app request the new data from your server upon launch - ie/ get anything new since last time the app was opened - this way it's independent of whether the push was received or not and depending on what your server sends back, you can clear the push count (or not).
Whenever application hits appDidBecomeActive delegate, clear the badge count to zero.