Objective C - Check running processes - ios

good afternoon, I'm developing for iOS using phonegap, but I need to modify some objective C code and I was looking for information, but I cant found anything about how to check the amount of running processes in the device (iphone or ipad)

There are no public APIs for this. The reason is that Apple probably doesn't want you doing it, because it violates their app-sandboxing philosophy. And really, there's no reason for you to do it in an AppStore app, because you are guaranteed to be more-or-less the only app running when you are running. There may be some music players or VOIP apps in the background, but they user probably wants them there, they are not pertinent to your app, and there's nothing you can do about them anyway.
What is the reason you want to list the running processes on the device?

Related

Can I make a purely voice driven app in Expo?

I want to create an Expo app for ios that will say something, and wait for my reply, via headphones. The headphones part is immaterial but it indicates what I want... which is for this to run while my phone is locked and in my pocket. Once I have replied, the app would proceed. I have built Expo apps but I am unsure of whether an app can still interact with me via audio and the microphone in this way while the phone is locked. Also, I don't know if Expo has introduced this sort of capability. I also don't know if React Native (i.e. ejected Expo apps) can do this sort of thing. The lack of apps that truly interact in this way (not via Siri etc) are far and few between so I'm assuming it's a hard problem to solve. I would be just as happy if I could have a browser page running on the device do the same thing, but I'm pretty sure webpages can't play audio and wait for replies when a phone is locked. Is any of this possible at this point?
I did research this online, just to be clear. I wasn't able to find an answer so I came here. I mention this because this whole post does have that 'can you research this for me' vibe. I'm just hoping someone has knowledge of what is possible.
There is a page in the expo documentation that says when not to use expo, and the following is in there:
The SDK doesn't support all types of background code execution
Background execution is the ability to run code when the app is not foregrounded or the device is sleeping. We support background geolocation (including geofencing) and background fetch, but we do not yet support background audio with the operating-system playback controls and you cannot handle push notifications in the background. This is a work in progress.
You can take a look at it here.
I think you can do it in React Native though, however I can't say if there is a library to do it, so you can try creating your own with native code. You can see how here for android and here for ios.

Can an app in development affect other apps on the phone?

I am having this weird issue while developing an app on iOS 10. Since I started testing it on my iPhone, other apps I have such as Facebook, Slack, LINE or Google Photos get randomly signed out quite often, like multiple times a day.
Could this be related to my app at all? It uses UserDefaults and Keychain to handle user log in/out within my app. I have a feeling that those two might have something to do with this but I'm not so sure.
I read that this was an issue when iOS 7 first came out but I found nothing regarding iOS 10. So I think it's just me.
Thank you for your help.
Unless there's some obscure bug in iOS 10, there is nothing you can do in your iOS app that can affect any other app. That's the whole point of sandboxing. One app can't mess with another.
This assumes your iOS device is not jailbroken and you are only using public APIs in your app. If you are using private APIs or developing on a jailbroken device, then anything is possible.

Objective C - Terminate all other apps running in the background

I need to develop an enterprise application, which should be able to close all other Apps which are currently running via multithreading on non-jailbreaked iOS-devices.
Some years ago I had an App called PKiller or Process Killer, which listed all currently running applications including their program ID and was able to close them. It was an App published in the official AppStore but of course Apple took it down, due to the violation of their guidelines.
Does anybody know how to get currently running processes and shut them down?
(again this App will not go to Apple / the AppStore, due to the fact, that it's an enterprise Application)
EDIT:
I did deeper researches and found out, that you can't even get any running or installed Apps and the connected information like the PID anymore in iOS 9. Apple made the sysctl no longer accessible to sandboxed iOS 9 apps. Also other methods in order to get any third PID failed in iOS 9.
There was a way to do it in the past, but as of iOS 9, it will no longer work. The library that was used for this, sysctl is no longer accessible to sandboxed iOS 9 apps.
In iOS 9, the sandbox now prevents a process from accessing the
kern.proc, kern.procargs, and kern.procargs2 values for other
processes
and
iOS apps are not permitted to see what other apps are running
https://developer.apple.com/videos/play/wwdc2015-703/
There may be another way, but it certainly will not be as easy as it was a couple of years ago, and not without major effort that Apple will be looking to shut down, even for enterprise apps.
I believe you can't do that because apple won't allow you to access the data out side on your application sandbox.

Can iOS apps communicate via sockets?

I'm going to develop few apps for iOS. Can they communicate to each other via sockets? Let's say one app runs as server (even in background mode) and another as client connects to server app and perform some communication. Does it violate any App Store rules? Any available IPC in iOS if my idea is not working for some reason?
Of course you can and it doesn't violate any rules.
Just just the CoreFoundation libraries.
There's no point in me describing it to you if it already has been all written in the official Apple documentation:
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html
You can find here examples, all approaches and things you can and cannot do.
EDIT:
You didn't make that clear but it seems like you wanted the apps to run on the same device. You can do that but that would mean that one app has to run in background, and to do that you need some kind of hack (for example: background updating location mode ON) and that won't get past apple store. You need a very good reason to have your app ran in background (music in background, update location in background for fitness apps etc.)
Besides, it's a duplicate question:
iOS - Is it possible to communicate between apps via localhost?
As long as your apps are in the same app group, then yes, socket IPC is allowed. If not, then no. Sockets map to file descriptors (Berkeley sockets), and these files are sandboxed to the app or app group. More info: http://ddeville.me/2015/02/interprocess-communication-on-ios-with-berkeley-sockets

Can an app keep running while the screen is locked, on a jailbroken iphone?

I have an idea for an app that I'd like to develop, but before I invest a lot of time learning objective C and the iOS APIs, I'd like to make sure that what I want to do is feasible.
The app I want to make is a purely auditory (sound-only) version of Google Glass. I'm visually impaired, so spending a lot of money on something visual, even though it can read content to you, would not be worth it. But if I could use an iPhone to give many of the same options as Google Glass, that would be great.
Many times, I've wanted a piece of information while walking down the street, where I couldn't easily get to my iPhone, because I have my cane in one hand, and something else in the other. In such cases, it'd be awesome if I could say a command, and get a voice response.
I'd use the microphone built into the Apple earphones for audio input, but I'm not sure if it's possible to listen for audio input while the screen is locked. I'm certain it's not possible with a non-jailbroken iPhone.
Can anyone can tell me if this is possible?
Yes, you can do this.
In order to keep your app running all the time, even when the iPhone is locked, you could build a Launch Daemon. A launch daemon can start when the phone does, and is not subject to the restrictions that iOS puts on sandboxed apps, installed to /var/mobile/Applications/.
You do need to have a jailbroken device to take advantage of Launch Daemons. Here is a good tutorial on building one.
Launch Daemons are also a normal part of OS X, so if you need more information, you might try consulting the OS X docs online. Most aspects of Launch Daemons work the same way on a jailbroken iPhone.
You'll also want to be able to detect certain events, to activate your app. You certainly don't want to be processing an audio stream at all times (maybe you only activate the app when you start walking with your cane). To detect events, like a home button press (or however you want to activate your code), I would take a look at RPetrich's libactivator library.

Resources