> you want to use some notification of charge to launch/activate your app?
Essentially, yes. More precisely, I need the app to be launched/activated somehow when charging begins; I do not really care whether the mechanism used for that is a notification or anything else.
> Do you want to launch the app or only to activate from background?
Well as “launch/activate” sort of suggest, I would need it to be activated if it happens to be suspended (or runs, which it very probably would not, see below) at bacground; launched if it does not run at all.
> As far as I understand, the first is not possible
Actually, a local notification (alerting the user who would tap the alert to launch the app) would be quite an acceptable solution — provided that notification could come exactly at (or very shortly after, let's say up to a second or two at very worst) the moment when the device starts charging.
Is that possible? As always, I can be missing something of importance, but I don't know such a local notification can be requested. Is there a way to do that? All I know are time- and location-based local notifications, none of which helps here the slightest bit.
> For the second, you could detect that the iPhone has been plugged / unplugged
Absolutely, provided my application actually runs at background, which is generally — again, far as I understand — not possible to achieve.
Again do please correct me if I am wrong, but far as I know, Apple does not allow applications to run at background, unless they play a (silent, in this case) audio, which is trick dirty enough for my client to frown upon, not speaking of the Store, which well might reject such a thing. There's also BGTaskScheduler now, but it won't make sure my app gets a few ticks of CPU at least each second, which is roughly what I would need; the new API, far as I understand the thing, might well leave the app dormant for minutes (or hours or days) 😟
If there's any other possibility to make my app really run at bacground (well, aside of VoIP which is not a solution for roughly same reasons as the audio-play hack) — or, even better, be reliably resumed at background each second or so —, I never heard of the thing, and would be grateful if you point it to me.
Thanks and all the best,
OC