iOS Swift Update To Web-service When Network Connection Is Available - ios

In our iOS mobile app we have forms to create, edit and delete certain resources.
We want a user of our app to be able to create and delete these resources when offline and have them update to the webservice when a connection is available.
On Android we use a library by Evernote based on JobQueues which allows us to schedule a job to run when the network is available.
Evernote Android-Job Github
Is there an equivalent technology available in iOS or what is the recommended approach to achieving the same queue effect.
On iOS we use Realm as our on-device database and Alamofire as a network library.

Realm Sync can accomplish this but you will need Realm Object Server on the backend and the reachability triggers as other's have mentioned.

Related

How can I efficiently use HealthKit's step count functionality within a Flutter app?

I'm doing research for an app I have to build for our start-up.
I want to build an app that keeps count of the steps a person takes every day by using HealthKit on iOS.
When the user requests a refresh or restarts the app, I can request the latest step count available. However, we want to push notifications to the user as soon as they have taken a set amount of steps (10,000 for example).
So I was wondering if I could set up a listener within flutter, so that HealthKit would (battery efficiently) provide the latest step count as they come in or at a set value/interval.
Is this 'listener'-architecture that communicates between flutter and native Swift code possible with flutter, and if so, is it the best approach?
Is the same also possible on the Android side?
Thank you for your attention.
Perhaps HealthKit's or HKObserverQuery is what you need on the iOS side
Receiving Background Deliveries
Apps can also register to receive updates while in the background by
calling the HealthKit store’s
enableBackgroundDelivery(for:frequency:withCompletion:) method. This
method registers your app for background notifications. HealthKit
wakes your app whenever new samples of the specified type are saved to
the store. Your app is called at most once per time period defined by
the frequency you specified when registering.
As for architectures that
communicates between flutter and native Swift code ... Is the same
also possible on the Android
I believe you are looking for Flutter Platform Channels where you can find a Swift Example.
Flutter uses a flexible system that allows you to call
platform-specific APIs whether available in Java or Kotlin code on
Android, or in ObjectiveC or Swift code on iOS.
Flutter’s platform-specific API support does not rely on code
generation, but rather on a flexible message passing style:
The Flutter portion of your app sends messages to its host, the iOS or
Android portion of your app, over a platform channel.
The host listens on the platform channel, and receives the message. It
then calls into any number of platform-specific APIs – using the
native programming language – and sends back a response to the client,
the Flutter portion of your app.
Unfortunately, I don't see any existing Flutter HealthKit but hopefully the available tools are enough to let you build your own bridge for HealthKit.
Brandon Donnelson's Video on Creating a Plugin may also help.
I am not sure if there are HealthKit alternatives to Android.

Keep users age up to date in Firebase with Swift

I'm building an app with user registration and I'm using Firebase as my backend.
I have used a date picker to allow the user to select their age and now I want to find out if there is a way for the age to be automatically updated in Firebase? It seems a bit tedious to do it manually.
Any help would be great. Thanks!
Firebase does not offer an option to run code in the background.
If you still want your data to be updated without any kind of user actions, you could use cloud services like Google Cloud Platform with its App Engine to run code from there, which updates all user ages according to the current year.
Google has some handy documentation on just such an environment.
Firebase and Google App Engine standard environment
App Engine standard environment is an application platform that
monitors, updates, and scales the hosting environment; all you need to
do is write your mobile backend service code.
If your app needs to process user data or orchestrate events, extending
Firebase with App Engine standard environment gives you the benefit of
automatic real-time data synchronization
Recommended for:
Firebase apps that need a backend service to modify the synchronized data.
Backend services that run periodically to process or analyze Firebase data.
Not recommended for:
Backend services that call native binaries, write to the file system, or make other system calls.
Persistent connections to Firebase. App Engine standard environment reclaims socket connections after 2 minutes.

How to establish bidirectional communication between two iOS apps

I have to establish bidirectional communication between my iOS apps. The data that have to be exchanged were text and json. Is it possible with the file sharing feature of app extension? If so, is there a sample that is available to guide through the steps? What are the pre-requisites to create the group id for app group?
You won't be able to speak to another bundle, this is more of an Android behaviour.
Your only way is to use an intermediate server, and that could be a complete book.
What I suggest, is having your files/data stored online, and build both your apps to be able to read and write on that server.

Real time syncing

I want to develop application same as UBER in which I need to show available taxis in the selected region and update as the taxis are hired, available, unavailable. Kind of auto refresh.
Calling the web service in the background after regular time interval is not a good option.
Can any one suggest me better and fast way to achieve this.
Thanks
Push
Use sockets when the app is running. This will give you immediate updates.
Use Push notifications when the app is not running (use notifications for critical changes), and ignore these notifications when the app is already running, in favor of sockets.
Pull
Use NSURLSession to refresh your local DB with some regularity. This is very resilient to network failure.
Use a combination of approaches, since speed and robustness are mutually exclusive. Ultimately, your objective is to keep your local DB in sync with your server's DB, and fire internal messages as data changes. No small task, hence the Firebase answer.
The Most Simple way is to work with Firebase . Its No sql database and you will have instant update as you change anything .
This Video will guide you how speedy you can get update without any loop for refreshing data in application .
Ask me any help you need regarding Firebase .
You can use silent push notifications to update your map with updated taxi locations.
I would suggest you take a look at CloudKit. There are several reasons.
If you decide to just build one app and somehow have driver
functionality that is different from users (maybe by having drivers
register and sign-in) then the app can post shared data to a public
online database accessible to all users. You could use information
in this scenario to post local notifications as the need arises.
As iOS updates you will not be dependent on third party libraries
If you decide to create a driver app and a separate user app,
CloudKit will allow you to share data across these apps.
Apple deals with the security and availability.
Overall the process is very easy to implement.
You can combine the local notifications with the public database to
schedule reminders, alert users etc.
CloudKit when done correctly will be essentially free. Just transfer
CKAssets rather than raw data and your transfer/storage limits
become negligible.
You can also access your CloudKit databases from external web
services/websites if you want to extend the data further.
You can use CloudKit subscriptions to sync up user information
automatically
NB - As pointed out in comments this is new technology. It is in the
second generation and I prefer it because if one uses it creatively
then you can simulate the external push notification behavior together
with background support. CloudKit removes the need for a third party web server from which to push the external notifications (as the real notifications take place by writing to the shared database).
Check out my detailed answer on SO for sharing the data between apps with CloudKit. Here is a link to some CloudKit videos that further describe how CloudKit works. Apple has lots of documentation and sample projects available. You can review the developer website for more info on CloudKit.
CloudKit Quick Start

How to broadcast bluetooth service in ios using corebluetooth?

If I want to have my iOS device act as a "server" and broadcast its bluetooth services to other iOS devices, how would I use the core-bluetooth framework (or any other iOS framework) to implement this? So far, all I've seen from the corebluetooth framework is how to write the client-side of things. (Scanning, connecting to existing bluetooth services)
You can make use of the OSX sample project called DNSSDObjects. The core classes (three of them) work just fine under iOS. The code requires a few small changes to work with Bluetooth (as-is they only work with WiFi). See my answer to another question for the required code changes.
Basically you use whatever code you need to setup your server and begin accepting socket connections. You then use the DNSSDRegistration class to advertise your server via Bonjour.
The other two classes, DNSSDBrowser and DNSSDService can be used by iOS client code to find the server, or any app or program that can find Bonjour services will also be able to find your server.
There are two great WWDC video that show how to act as either the client or the server using an appropriate iOS device. They can be found here, you're looking for sessions 703 and 705.
Downloads of the source that they use can be found here. You'll need a developer account (free works) to login and view/download.

Resources