send event from server to an ios app - ios

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

Related

Local notifications vs. APNS: can I have a timer periodically fetch notifications and schedule them locally to avoid using APNS?

I am new to iOS development and am building an app with SwiftUI. In the background, I periodically pull down state from the server and the displays update accordingly.
I'd like to add notifications to my app, so when an important state change happens, the user gets a popup on their lock screen. It seems like the simplest approach would be to make an endpoint in my backend that returns notifications for a given user, periodically pull that data in the background of the app, and schedule notifications locally as necessary. This it seems would avoid the need to use APNS, but effectively accomplish the same thing.
Which makes me a little suspicious that this solution actually works. Would this solution work even if my app were running in the background? Are there any downsides to doing it this way versus using APNS that I might not be seeing?
TIA!

What is the best way to keep updated the info of an iOS App?

Since push notifications may not be delivered sometimes (you can lose a few of them), you can not run code after the iPhone is turned on to check if there is new information available from the server, and you can not run code if your iOS App is closed... What can you do if you want to be as more accurate as possible in for example a Chat App in iOS?
I mean, inform the user as faster as possible that he has new info available. Comparisons: WhatsApp is updated without any delay.
You can do background fetch if your App is in background. But if the App is closed and you miss a push, it's not going to be up to date until the next push arrives or user opens the App. The same with silent notifications. If the app is terminated by the user, you are not going to receive it. Is there any way to solve it? It must be because other Apps do it... If there is any "private and secret" API that they are using (I read about this answer when no one know how to do that)... Is there any way to apply to use it?
UPDATE:
I'm using push notifications. The goal is to fix when a push doesn't arrive. Example: User A send chat message to user B. User B doesn't have the App open. The system lose the push. User B is not going to receive the message until he open the App.
Push notifications seems to be your only way even if you do loose a few of them, which I don't know how you would since they are pushed to apples secure server... but what do I know. As long as the user turns on the push notifications you should be fine. They may be delayed due to apples way of handling them. Honestly push seems to be the future, having your app constantly every minute or two check for new messages is a huge battery water in conjunction with normal texting apps. Your app should provide the best live data but since apple restricts to push notifications when the app is off or not running just stick to push notifications and only push major events to the user. I believe you can set up a job scheduler using quartz or schedulator to setup your server to push notifications to your app.

Is there a way to keep CoreData in Sync with a Server API even when the App is in Background/Suspended/Terminated states?

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

IOS/Android app custom push notification handling

I want to develop an app, but before I actually start developing, I've been doing some research so that i can be sure it's going to work in the way I'd like to do this.
You can imagine the app as a kind of news app, where the user can indicate whether he wants to receive push notifications, and may also indicate that he only wants to receive a push notification if it is in X distance from his current location.
And this is probally a problem on IOS, On android it would be no problem if a push notification came in to read the current position of the user and settings and then show the push notification or not.
As far as I've read this is a problem on iOS, the system receives the push and the app can not respond to it unless the user clicks on it.
Theres also another problem about closing an app on IOS, ideally a app should not be closed (swiped out) by the user because this would be a force close on IOS.
From ive seen most users still swipe out apps, and this would mean that my app cannot run background tasks anymore.
This is what i thougt about:
Send Silent push, app download data on the background -> Check if this meets the user settings, if so show a local notification. (30 sec time to handle, but do not know if it is possible to throw a local push here too.)
The app sends data on the background over the user's current position before sending a push, the server checks for which apps it should be sent (actually no solution, too much data usage as it may be that the user is only one Specific location, need a good server if the app is used on thousands of devices.).
Does anyone have any idea how to handle this problem?

Refreshing data without push notification

So I have build a chat,
Right one user1 sends text to user2.
user2 gets push notification, if the app is open then using the push notification code I'm re-downloading the data from server.
So my question is, is there any way to reload data without push notification? like find when the content is available and download the data and reload the chat.
I'm pretty new ios programming so I don't know whats is exactly called or any ways to do it without getting a push and running a function.
There are only a couple of ways for a server to reach out to your app. Through push notifications (both silent and normal,) and using a socket. Sockets are more immediate but only work when your app is active in the foreground.
The only other option is for your app to poll the server. IE, for it to call a server outlet every few seconds and ask if there is any new information.

Resources