Launching an iOS app on device reboot - ios

I want to write an iOS sample application which can launch itself whenever device is rebooted. Please share your thoughts and any pointers will be really helpful.
Setting VOIP in background modes seems to be one option.
I am NOT looking for a Jail break solution.

There is a way if you have access to MDM tools or the Apple Configurator, and are able to control the device and its' profile. For example, if you are the curator at a museum or you or a teacher and hand out iPads to students, you'll most certainly have this level of control; and since you're writing a sample application, I suppose this level of control is possible as well.
There is a feature known as Single App Mode (see page 17) that locks a device into a single app. According to the documentation, if the device is powered down, the specified app will launch at boot. (I don't have the setup to confirm this.)
Note that Single App Mode is not the same as guided access mode, though people do tend to get them confused.
So should you have access to the right tools your original intent may be possible.

There is really not much you can do to achieve such functionality. The most you can do is to provide background fetching to prepare your app for when user launches it explicitly.
I have never seen a single app that could launch itself for no reason.
Hope this can be useful.

Can't be done unless the device is jailbroken, and I can't help you with that.

To my knowledge, this is not possible. Your app does not have access to this level of system information.
What you could do is periodically send push-notifications with a payload that temporary allows you to access app functionality.

Related

How to programmatically turn on/off WiFi in iOS? [Swift]

NOTE: I am aware that such a thing violates user's privacy and would be rejected by Apple. However, this specific component is purely for automated testing of buffering behavior when the user's connection is poor/nonexistent. It will NOT be publicly released.
With that said, does anyone know of a way to programmatically turn on/off WiFi in iOS?
I have not been able to find anything up-to-date. Pretty much every answer has to do with this being a violation of privacy and cautioning that they shouldn't do it. Doesn't apply in my case.
Closest I could find was using something like DeviceFarm to simulate it https://docs.aws.amazon.com/devicefarm/latest/developerguide/how-to-simulate-network-connections-and-conditions.html
However, in my case I want these tests to run entirely within the app (private test build). Setting up DeviceFarm for this purpose alone isn't worth it imo.
There is no provision provided by apple to change automate changing its settings because of apple's privacy rule. So you can't achieve by any way.
You can’t. Apple does not allow 3rd party apps to change global system settings like that.
There is no API available to control cellular data,wi-fi,bluetooth within in an app , User have to go to settings to enable or disable cellular data,wi-fi and bluetooth.
This is not possible in iOS unless you jailbroke your device. Apple is not allowing any apps developer to access wifi/bluetooth. You can only check wifi/tooth is connected or not.
You can’t do that using the iOS application. Apple not allowing it.
Legally there is no way to do it. Even somehow if you are manage to do it, Apple will reject your app while submitting to AppStore.

Is it possible to have a running background app on iOS

This is a strange one, I have a need to create an iOS app that runs in the background on an iOS device, but can not be visible on the Home screen of the device. The app may need to show up in Settings to configure a few options, but it mostly needs to run behind the scenes.
I do not need to publish this app on the app store, it is strictly an enterprise app for my company.
Does anyone know how this kind of behavior might be achieved? Configuration profiles? API's? etc?
Edit: Jailbreaking the device is not really an option for us. We have to keep the devices as they are.
Backgrounding
There are several methods to get permanent background execution:
a) Silent audio which is mentioned by JRG-Developer
b) Usage of beginBackgroundTaskWithExpirationHandler + turning location manager on/off (it will reset remaining time to 600 seconds)
Making app invisible
You can use SBAppTags in Info.plist (take a look at this: How to remove app icon programatically from jail broken iPhone app?)
It will make your icon not visible on Home screen.
I've no idea how you can tackle the not be visible on the home screen criteria, but there are certain services that are allowed to be run in the background continuously, notably:
Background Audio (even silent audio)
While this is indeed very hacky, short of jailbreaking the devices, this may be your best bet.
While it's unlikely / very difficult to get past the review process, in the event for some reason you do need to (attempt) to publish this app to the App Store, some apps are even available on the App Store which take advantage of this hack, such as PasteBot.
You should definitely read their write-up here about getting their app's Cut-and-Paste functionality to work while in the background:
http://tapbots.com/blog/pastebot/pastebot-music-in-background
Another out-of-the-box idea, why not use Android devices instead, which do support multitasking?
Two methods:
Jailbreak. A jailbroken iPhone is essentially a Mac and you can use all Mac UNIX programming tricks - spawn a daemon (you can even ask launchd to do that), or something. You can set up enteprise-wise Cydia source. Refer to saurik's website for a walkthrough and set up an experimental server using Ubuntu (which used apt too)
A non-jailbreak way may be possible, but it will depend on what your app is doing. You can try use enterprise-wise push notifications.
Given that this is impossible to do on non jailbroken phones, I'd suggest the following:
develop a directory app, or a phone list app, something that is specific to your company.
have it connect to a web service once a day to register the device ID (so you know the user has not deleted the app)
tell users they need to keep the app open at all times (and if a user's device does not register one day, send them an email asking them to launch the app).
Now you can send back whatever you want with the app. If they kill it, you'll know the next day when you have a script look at the logs.
If you think this is a terrible idea, it is, but its the best you are going to get on iOS right now.
EDIT: you could send a notification every day - say in the AM - to make sure the user opened the app if it wasn't running.
From my experince, this kind of behaviour cannot be achieved on iOS. When an app enters into background, it is active only for a small particular amount of time. After that, it goes into hybernate state. It stops working. So the behaviour you said can not be achieved without abusing iOS workflow. Thats why some call iOS's multitasking as not true multitasking. Only jailbreaking might help your case. That was for one case. The second one where the app cannot be seen on home screen is again, impossible. It has to be on springboard to run.

Run app "as a service" on iOS / Cydia

I'm currently trying to create a little app that should run in background. It should start with the system or springboard and run until the device shut's down. I searched for tutorials out there but doesn't found anything really useful. It would be great if someone would help me out.
Best regards
EDIT: I'm sure that it isn't possible in an app designed for the appstore, but i'm looking for a variant that work's on jailbroken devices.
ColinE's answer is wrong. SuperDev's is correct. You certainly can create services on iOS, just as on OS X.
As another reference, the best tutorial I've found on the subject is Chris Alvares' blog post on creating an iOS Launch Daemon. (Launch Daemon is the proper iOS terminology for what you're describing)
You may find additional useful information within the Apple Docs for Launch Daemons, or searching for OS X information, instead of just for iOS, where it requires jailbreaking (and therefore is less widely used).
Cydia has lots of apps that are launch daemons, or contain launch daemons (possibly in addition to a UI application).
Have you read about launch daemons? You could use one of those. An example is untrackerd by rpetrich, an awesome cydia developer.
This is not possible, you cannot create 'service' type apps:
iOS: Keep an app running like a service
This is by design. Apple limits the the capabilities of your apps in order to ensure a good user experience. If everyone could create background services, it would soon slow down the user's phones - like a Windows PC!
Have you tried reading about Mobile Substrate? It let's you build extensions for the springboard. That way you could run the app in the background.

Custom iOS lock app

I'm looking to write a custom lock app to replace the default PIN lock on iOS.
As there are no apps like this available on the App Store currently, its clear that either Apple rejects these types of apps or its just not possible with the currently available APIs.
The app is just for personal use, but I'd just like to know if it's possible before starting. Anyone know which is the case?
Thanks
You can't replace the standard lock screen or PIN entry keyboard EXCEPT on jailbroken devices. First, there's no way to do it with the official SDK. Secondly even if there was Apple would not allow you to modify any of the system applications. If you're serious about doing it though for "personal use" and are OK with voiding your warranty (and/or possibly bricking your device) you could look into jailbreaking and the tools available. A hint in the right direction would be to learn as much as you can about SpringBoard and mobile substrate. Hope that helps.
It's not possible with the current APIs. As soon as someone pushes the home button your app will be sent to the background or terminated depending on how it is configured.

How does an iOS screensaver app work?

A client of mine recently came up with a few apps he came across while browsing online. Specifically, he discovered that there are apps that call themselves 'screensavers', and now he wants me to make him a screensaver app.
The obvious problem is that I don't know of any way to make my app open (displacing whatever is in the background) based on a lack of user input in another app! In fact, I would have sworn that it was completely impossible to do so.
So, to wrap up the question -- is it possible to make such an app, and if so how? Or are those apps really, really, badly labeled?
I just tested 3 of the top "screen-saver" applications on my iPad. None of these can turn themselves on, without the user launching them. They are really badly labeled products. In a non-jailbroken device, launching the screensaver application without user interaction is not possible.
Cydia Screensaver Application for Jailbroken devices.
You're correct -- it isn't possible to open an app with no user interaction with a stock device, although there are jailbroken packages that will complete a task similar to this.
You should explain to your client that these "screensaver" apps usually gimmick the reader into downloading them as if they function as do screen savers on personal computers.

Resources