Can i run WebSocket server in background application in iOS - ios

When i tried to implement app stays unto 3 mins after socket is not running.
My requirement to develop one socket server app that should be always in background.Needs to communicate with other client apps or safari web browser client .
I need to communicate between server app and other clients apps or other browser.
So, initially user opens the server app and click start server button.Then he can go to other clients apps and get communicate and share valuable information.
In this process server app needs to stay in background continuously for a long time.Untill the user terminates the app.
I saw that app need to use some UIBackgroundModes to communicates like
• Apps that play audible content to the user while in the background, such as a music player app
• Apps that record audio content while in the background
• Apps that keep users informed of their location at all times, such as a navigation app
• Apps that support Voice over Internet Protocol (VoIP)
• Apps that need to download and process new content regularly
• Apps that receive regular updates from external accessories
But i am using only external accessories in my app.That i am attaching some reader to iPhone/ipad device.
• Apps that receive regular updates from external accessories
I saw many links in Stackoverflow, but i dnt get proper answer.
Some links:
socket connection killed after iOS app goes to background
iOS application executing tasks in background
https://blog.newrelic.com/2016/01/13/ios9-background-execution/
Can you guys can suggest me how to keep the app in background??
Thanks in advance

Related

Is it possible for an Apple Watch to get data directly from a Web Server without having an iPhone as an intermediary?

I'm creating an app that wants to get a JSON file (or any data) from a local web server (MAMP) without having an iPhone that communicate with the server, parse the file and eventually sends the data to the Apple Watch via WatchConnectivity.
Is it possible? Is there any API I could use?
I've seen that the apps preinstalled on the watch can get data from the Web even with the iPhone turned off relaying only on the Wifi connectivity: for example the Apple's map app.
Thank you!
Yes. As long as the watch has a network connection, via WiFi, cellular or through Bluetooth to its paired phone then you can use networking features, such as URLSession to fetch web content.
Even if the watch does piggyback off the phone's network connection, it doesn't require you to send data "through" the companion app.
As of watchOS 6.0, watch apps don't need a phone companion app; they can be stand-alone.

Does Apple permit the usage of socket for communication between two iOS apps?

So basically I have two iOS apps installed on the same device, and they need to communicate by sending data to each other. I don't want to use URL scheme or Universal links as these two would open the other app in UI instead of sending message to each other in the background. Currently I have a solution of using a unix socket connection by binding one app to a specific port and have another app connect to it. This works fine but I am just wondering if Apple would allow the usage of this.
Note that these two iOS apps do not come from the same developer so anything else that relies on App Group would not work in this case..
Would Apple allow using a socket in this case?
Edit: One of the app is valid to run in background, so background execution is not a problem
No, this is not possible simply because the application will lose network connectivity when it goes into background mode. I invite you to check the following Apple Developer Documentation page related to iOS app background modes:
Background Execution
As you can find on the page, the operating system suspend the app when it moves to background and will then cut several resources including network access.
There are however some exceptions to the rule, which are voice ip apps. These must declare the voip background mode in the plist file to be allowed to keep network streams open in the background.
This question comes a lot on iOS or Android and unfortunately the answer so far is no, we can do tcp client / server communication between apps.
It is totally doable as long as one of your apps has permissions to run on the background. Such example is music apps. Spotify does the same thing with their “app-remote” SDK.

Using a Website to Recognize Google Beacons

As of KitKat 4.4, the required proximity API is baked into the Nearby functionality of the Android OS. This means that Android devices no longer require an application to detect and interact with beacons.
iOS, however, still requires either an app or the chrome browser to do so with Google's beacons.
My question: With current technology, if a website is designed using Google's PWA standards, can it have the ability to detect and interact with beacons in the same fashion that an application would (regardless of the browser being used)?
Follow-up, if YES, would it be able to perform these tasks while open in the background?
The short answer is no, you generally cannot interact with beacons from web apps. This is true even on Android devices that use the Chrome browser. On Android, you can launch a web app on beacon detection using Nearby, but only if the user taps the Nearby notification.
Here's the longer explanation:
Android devices do support Google Nearby which allows you to send a notification to a user when your beacon is detected that can (a) launch a native app, (b) launch the Google Play store to install an app, or (c) launch a URL in the default browser.
When launching a URL, the URL can be to a web app and may include a URL parameter that tells it that the web app was launched by the beacon detection through Nearby. But once the launch of complete, the web app's interaction with beacons is over.
In order to have dynamic interaction with beacons, there must be web APIs that give the web app callbacks when beacons are detected. These currently do not exist. There is hope for this in the future using Web Bluetooth APIs (See: https://webbluetoothcg.github.io/web-bluetooth/), however they do not currently support scanning for arbitrary Bluetooth advertisements needed to detect beacons.

App Analytics for device where network connectivity varies

Attempting to set up analytics for a react native app, and was going to use something like https://www.npmjs.com/package/react-native-google-analytics.
An issue though, is that there are times where the device may lose network connectivity. Are there any good libraries/solutions for storing events/views app side, then batch uploading them to something like google analytics?
You could use the actual iOS & Android SDK for Google Analytics, via the following react native bridge - https://github.com/idehub/react-native-google-analytics-bridge
As per docs for iOS & android
If a user loses network access or quits your app while there are still
hits waiting to be dispatched, those hits are persisted in local
storage. They will be dispatched the next time your app is running and
dispatch is called.

iOS - Possible for Safari HTML5 Web Sockets to Communicate with App on Same Device?

Is it possible to use html5 web sockets in mobile safari to communicate with another app on the same device? Basically, I'd like to build a socket server in a custom app and have my javascript on a page in mobile safari send messages to it via html web sockets. I have very little experience with sockets and just thought I'd throw this idea out there.
No -- there is no background mode which will allow a native iOS application to "legally" keep a socket server running. The only three modes which can fully run in the background are "audio", "VoIP", and "location", and your application probably wouldn't fall into any of these categories.

Resources