ordex, thanks for your quick reply.
ordex wrote
Have you tried sniffing your traffic to see if packets to that IP class are actually going out of the tunnel?
Following your recommendation, I analyzed the packets going via WiFi and VPN, and also investigated a bit the push mechanism.
Basically, there 2 push mechanisms: the old one (UserNotifications framework) and the new one (PushKit framework, mainly intended as a low-latency interactions mechanism for messengers and VoIP + some other classes, details: [1], [2]). In both cases, the phone opens a TCP connection to APN servers and maintains it. With the 1st mechanism, when a push notification is to be delivered, APN server sends it to the phone via the TCP connection and the phone gives the user some feedback.
But, unlike user notifications, PushKit notifications are never presented to the user - they don't present badges, alerts, or sounds. PushKit notifications wake up the app (or launch it if it's not running) and give it runtime to process the notification, even if it's running in the background or the phone is "sleeping".
With the 1st mechanism, whitelisting the APN servers' IPs is enough, but for the 2nd mechanism to work, the app servers' IPs should be whitelisted too.
So, for WhatsApp I had to whitelist (on top of the 17.0.0.0/8 block) 31.0.0.0/8 and 169.0.0.0/8 networks. With these routes, WhatsApp notifications started to work normally. But only WhatsApp's. Telegram was not working with these routes, logically.
As a conclusion, for thousands of apps to have push working with Seamless Tunnel one would have to whitelist the entire internet. Needless to say, this completely defeats the VPN purpose.
At the same time, without Seamless Tunnel what actually happens is that the apps communicate freely in the background without VPN. When the user responds to the notification and a VPN tunnel is established, the already opened TCP connections of the apps stay open and go outside the tunnel. Only when the apps reestablish their connections, only then the connections start flowing via the VPN. And this, basically, defeats the purpose of redirect-gateway.
Summing it up: for redirect-gateway to work as intended, Seamless Tunnel should be turned on, and with this setup for push notifications to work VPN should be always available.
ordex wrote
However, it is not granted permission to stay alive during sleep because, in my opinion, it would basically defeat the purpose of the sleep: to stay functional the entire device network stack should stay always on, thus draining the battery (instead of sleeping).
I don't know the internals of iOS networking so I may be completely wrong here, but I guess for a TCP connection to the APN servers to stay open during sleep the entire network stack should stay always on in any case. The only thing that would be added on top of this is that for each packet that goes via this APN connection the VPN encryption would have to be added/maintained. Again, I don't have a deep understanding of iOS internals, but I guess that this won't significantly impact the battery.
And, after all, even with heavy impact on the battery, the user may prefer to charge the phone more often than not be able to receive calls and messages or have to lessen the security/privacy by leaking connections with Seamless Tunnel turned off.
With wireless charging (on newer models), battery impact, no matter how heavy, is almost non-perceivable nowadays. Even if you say that with VPN always-on the battery would last only 5hs in standby without recharging, this would be an excellent solution in any case. Even with 2hs it would be an acceptable solution, but I know it'll last much longer as I can watch videos on YouTube via VPN for 2hs and the battery won't discharge more than 50% (I have an iPhone 6S).
Please let me know if I can sponsor the always-on feature development or help with it in other ways.
[1]
https://developer.apple.com/documentation/pushkit
[2]
https://www.sinch.com/tutorials/ios8-apps-and-pushkit/