iOS Offline data buffer - ios

Greeting everyone,
I am looking for a simple way to but my data in a buffer if I ever don't have access to Internet for a certain time.
Lets take a GSP app as an example: I am somewhere with no cell tower but my GPS registers my location. Then when I gain Internet back, it will send these location to the server.
I am currently using restkit to post my objects to the server. When the object is sent to the server, I don't really need it on the phone. So in a way I don't need a 1:1 sync between the iphone and the rest api.
The only idea I have is to have a simple local database (SQLite ?) and monitoring the connection, So I insert in the database when its offline and as soon as the connection is back up, I send the rows and delete them from the local database.
Anyone has a better idea?
Thank you
Jonathan

Related

Mobile Chat application on Google App Engine and Socket.IO

I am creating a chat application with Node.JS's Socket.IO and there is a couple things I need clarification on.
I am implementing offline messaging in my app meaning that when a user opens the app he will receive all the messages he missed when they were online.
This is my approach:
1) Client opens the app and is subscribed/joins a room
2) The client sends a message to Socket.IO
3) Socket.IO inserts the message in some kind of database/datastore
4) When client tries to retrieve the messages it is pulled from the database/datastore and saved on the users phone then it is deleted from the database.
Is this a correct approach?
I was looking at online and some people suggested using task/message queues like Google App Engines Task Queue but I am not sure how this works.
Your approach sounds OK, but I wouldn't delete messages from a DB, at least not immediately after the client receives them.
From your question it seems that you're not currently saving the messages to a database.
This approach has some drawbacks; for example, the user can't view their chat history on a device that was not connected when some of the messages were sent.
There are 2 ways I can think of to do it in a more elegant manner:
Save all messages to DB. on websocket connection and reconnections, fetch all messages newer than your latest message (This approach assumes no edit functionality in your chat, as edits will not be fetched this way). The latter can be implemented using either HTTP or WebSockets.
If you don't want to store the messages in your server, then you should implement some sort of persistent cache in the device used to send the messages. This is very similar to your original solution, except that instead of storing the messages in a database, you're storing them on the user's device. this does require some logic to detect when messages are received, and when the recipient reconnects, in order to trigger sending the missing messages.
The first approach is much better for the general use case in my opinion, but it depends on your use case.

Is there a clean way to limit Realm Object Server sync to wifi connections only?

I am in the middle stages of an app development that uses Realm on the iOS handset and will synchronise data to ROS. The amount of data that it could generate could become quite large, so we would like to offer the user the choice of only synchronising when they have a wifi connection to protect their mobile data quotas.
I could achieve this by being careful about when the app logs on and off the server, but that is messy and will likely lead to errors.
Is there a clean way to set up the synchronisation engine to only perform syncs when the server url is accessible via a Wifi connection?
There is no way to limit sync on WiFi connection only, unfortunately. We have put it on our task list. https://github.com/realm/realm-mobile-platform/issues/143 It will be implemented in the near future.

Online Data Storage and Transfer with Swift

I am trying to make a series of applications which require the user to make an account and login, therefore they could use the application on multiple devices and have the same data (e.g.. amount of virtual money and player score is about it), however, I have no idea how to go about this, I have decided it would be best for my app not use the apple GameKit (game centre) as it has a lot of limitations (e.g not showing usernames). What methods could I use to do this? Do I need to learn another language
Thank you
You can try Firebase, which serves as a backend especially for mobile applications. Basically, send a kind of a POST request to Firebase when the values you want to store have been changed in your game and send a kind of a GET request to fetch the said values to your mobile app(s). By this way, you can store data on Firebase and fetch it via multiple devices when the same user logs in from different devices.
For more information and a quick start, check this link: https://www.firebase.com/docs/ios/quickstart.html

How to make iPhone app sync data through laptop?

Currently my application is getting data from remote server through web services. But some times user are in area where network is rarely available. So in that case I just want to sync data for application through their laptop (window or mac).
For example I need to sync 100 images in to the app. I create an environment on laptop where I create a folder and keep images there and once iPhone get connected to laptop through wifi all images get synced with the application.
However I don't want automatically it can be usually on button action. But please guide me is there any way?
Just create a web service on the laptop and use that to do the storage. I have done similar things and I have gone the route of storing data locally in a Core Data model and then syncing to a server when the user comes back within range.

How to switch off iPhone Internet and data package network connection?

I want to make an application that tracks the total consumption of Internet data or in other words a data tracker. If the set limit is reached I want the Internet data package connection to be disabled.
Is it possible with the iPhone SDK? If yes, then which API and the library should I be looking at?
Manipulating the core system preferences (disabling data packages) and measuring packages sent and received are both outside the "quarantine-zone" of the Apple Developer Guidelines.
If you DO happen to find some tricky way to do this (that is, the private iOS frameworks) you must know that your app will never be approved.
The closest thing that comes to this was the talk about a statistics API, where apps could see the number of calls made, data transferred, etc.
But this was not very well looked upon by the approval board, and will probably not be a reality any time soon.
You can't do this without going the jailbreak route. What you could possibly do is maybe show a notification to the user if they are near to reaching the limit.
To get the amount of data consumed, some service providers provide APIs (I'm thinking of the consume app) where you can get the data consumed and data left from the provider side.

Resources