how to upload location data to server ios 7.1 - ios

Hi I am creating plugin which will detect get the location from user and upload it to the server.
when app is in the background it is working very well I am getting new location and it is getting uploaded to the server. But the problem comes after 20-25 mins. I get the new location update from the device but it is not getting uploaded to the server. I implemented local notification to know whether I am getting the new location or not even I create local notification when that data will get uploaded to the server. but after 25/30 mins I just get notification about new location not for the successful server update. I checked with the server database also.
Whenever I get new location I am storing that in to a local database and for server uploading I am taking that data from database.
I Read some of the post about beginBackgroundTaskWithExpirationHandler But it won't work in ios 7 or later. And my app is getting callback in the background so I don't think so background fetch also will work in this scenario.Can anyone have implemented something like this? anyone tested it after 25-30 mins? Help appreciated

Related

Firebase - know when data was saved to server after the app has been restarted

Imagine a chat app (iOS + Swift), when I send a message, I first save it with state "Sending".
Now I want to change the state to "Sent" only after it arrived at the server.
How can I achieve this?
setValue:withCompletionBlock: won't work, because if I close the app while offline, the block won't be called when I open the app again.
you can let the message model with a parameter named state and save it to local before sending to the server , when you open the app you can check messages with server

How to periodically call to a webservice even when the app is in background?

I want to do some server pulling in my iOS app. It something like this. When m app installed it should start a background service to check weather is there any new data available since the last updated date. If yeas my app should start a local push notification. How can I do this? I want to know how I can periodically check is there any new data available in server even when my app is in background.
Please help me.
Thanks
On iOS 7 and above, you have Background App Refresh. It's covered in the documentation under Fetching Small Amounts of Content Opportunistically. You can read more about it under Use Background App Refresh.
One caveat is that the user can turn off Background App Refresh for your app.

ios - Bulding an app that have push notification appear on a specific time interval

I'm building my first application.
I'm making app where I'm doing some fetching from rss feed of web site and loading it to a TableView. What I want is next:
-to inform a user when new feed arrive, when my app is closed (user can set the time interval of update frequency in app settings page) - with Local Notification
I'm using NSURLSession for downloading data, storing it with Core Data, and want the Deployment Target to be iOS 7.1.
Just want to know is it possible and steps that I need to do to implement it correctly.
What you want is called Background Fetch. Background fetch can fetch data from your servers even when the app is not running.
Local notifications would be of no help here. Even when a local notification has been fired, user will have to click on it to fetch data.
Look it up. There is a pretty decent tutorial here.

Manage iPhone app both offline and online

I am stuck to a point, I am managing my app offline also.. first time i get all data (images) from a webservices and store its path into sqlite, now I take an int value 0 or 1 and store its state into NSUserDefaults now I am facing problem in updating those images, like if images are changed how should I notify into my app, I searched it on Google and only solution is to send push notification to app when record is updated. What if user do not allow push notification?
Is there any other solution to manage app offline and update only when record is changed from online database?
You can sync your Data with server Periodically , like call a webservice which check if images have been changed then fetch the new images and if images are not changed then continue with old data.You can add a Boolean Value on server end which can tell you if data on server is updated or not or you can check this with Time stamp like when data is updated last time then compare your local time with Server time at which data has been updated . Good Luck !!
There are ways to handle such kind of situation:
Use push notifications which is the best solution for such situation.
Query the server periodically by giving the ability to the user to set the time interval from app settings.
Query the server whenever the app came from background to foreground.
An idea is to use BackgroundFetch to update the app content while it is not running. I am using similar fetch for one of my apps where I update the content before the user opens the app. I am fetching a small list of items that is indicating which one is up to date and which is not. Then, at runtime I present an option to the user to manually update these items, but of course you can also download all that while in backgroundfetch. My app is without network reach most of the time, and backgroundFetch will update the items list first thing when there is some internet connection.
There are two important methods here that you need to register, setMinimumBackgroundFetchInterval: and application:performFetchWithCompletionHandler: . You can read more about them in Apples guides for background modes.
You can also check out this good tutorial about this fetching capability: http://www.appcoda.com/ios7-background-fetch-programming/
There is way which has being most popular as most of peoples are preferring
At server side build mechanism, which can send lists of images updated after particular date/time.
To keep track of last sync date/time at locally.
Pinged on server with last date/time in case of first time pass any past date and check for update, if there is then download updated images, Otherwise.
Now you have to decide this process when would be query to server
1) At every first time application will be load. (At didFinishLaunchingWithOptions).
2) Query the server periodically by giving the ability to the user to set the time interval from app settings or else where would be preferable.
3) Query the server whenever the app came from background to foreground.

iOS - Background Transfer Service for Auto Update data at fixed intervel

I am developing an app of feeds, that fetches feed from server and display to users for read. It working fine when app starts but i want to load data in background when is suspended or terminate(in both case). As we can create IntentService in android and with a AlarmManager we can start that service after a every fixed hours (for ex. 3 hours), so whenever user comes to online he will be able to see latest data without waiting fetch for new feeds.
I have read Background Transfer Service & NSURLSession with silent remote notification but i could not understand how this will help me to achieve my objective.
When getting a remote notification how can i resume a NSURLSessionDataTask form AppDelegate.m file because we can't use delegate there.
Please help me to sort out this issue. Googling from last 2 days but didn't get success to achieve this.
You need to use Background Fetch instead of Background Transfer. Main purpose of Background Transfer is uploading or downloading files while when app in background state.

Resources