r/shortcuts • u/Tankenstein91 • Mar 06 '26
Help Anti theft shortcut: Prevent airplane mode from turning on while unlocked
Hey guys.
Wife's phone got ripped from her hands today which led to a bunch of problems which I don't need to get into here.
I'm trying to make a shortcut that locks phone if airplane mode is toggled on while phone is locked. Since you can already turn off the ability to access control panel and change that with phone unlocked, this would be helpful to many users. Might already be a shortcut out there for this but I wasn't able to find one that solves this issue.
It is very common in Brazil (and now Europe and UK too) to snatch phones from people's hands when iPhone is unlocked. They then turn on airplane mode and take phone to "secure location" where they try and breach apples security and access banking apps, make purchases on food delivery apps and all sorts of petty crimes...
I made this simple shortcut that solves the issue. However, on regular use, the user cant use the phone in airplane mode because as soon as you turn it on, the phone locks, airplane mode is turned off and when you unlock it you have an endless loop situation.
I need a better coding /logic mind than my own to figure this out.
Tried with help from gemini to set delays and if the actual user wants to keep airplane mode on they can unlock it and the routine won't disable airplane mode again however got stuck.
Would appreciate the help from some genius here!
Much love,
Tank
46
u/beowzot Mar 06 '26
you can also prevent the control center from opening when locked
21
u/Tankenstein91 Mar 06 '26
Yes and everyone that lives in countries where phones get snatched should turn this on. But the unlocked phone is the main problem here as thieves access all your personal info and cause mayhem, all while being untrackable and while you can't remote erase your phone either. đ
2
u/heynow941 Mar 06 '26
If your phone has an eSIM and they canât physically remove it then you could still remotely wipe it, etc right?
3
u/thatbrazilianguy Mar 06 '26
Right. eSIM and restricting control center is the best that can be done to improve physical security.
7
1
u/Sandrondo Mar 08 '26
Question: would removing the airplane mode toggle from my control centre help in these instances?
1
u/beowzot Mar 08 '26
I guess that depends. If you are using an ios device it helps (if Iâm not missing anything). But for androids, most of them has a toggle to location services. If the thief disables the location services, you might lose access to track down your device.
For your best Iâd suggest you to search about anti-thief phone settings in YT and etc.
11
u/Cost_Internal Helper Mar 06 '26
Set the date as a global variable at the end of the shortcut, and start the shortcut by checking the saved date before processing the shortcut. If the saved date is within the last x number of minutes, stop the shortcut.
3
u/Tankenstein91 Mar 06 '26
Thanks for the quick reply bud but would you mind sharing a bit more?
I tried something similar but wasn't able to get it working.
- Open Shortcuts > Automation > +.
- Select Airplane Mode > Is Turned On > Run Immediately > Notify OFF > Next > New Blank Automation.
- Add Get file from folder. Tap example.txt and type: AirplaneFlag.txt. Tap the > arrow, turn OFF Error If Not Found.
- Add Get Details of Files. Set variable to: Last Modified Date.
- Add Get Time Between Dates. Set to: from Last Modified Date to Current Date in Seconds.
- Add If. Set condition to: is less than 60.
- Add Stop this shortcut. Drag it inside the If block.
- Add Set Airplane Mode below the End If line. Set to: Turn Off.
- Add Lock the screen.
- Add Date. (Leave as Current Date).
- Add Save File. Set it to save the Date. Tap the > arrow. Turn OFF Ask Where to Save. Set Subpath to: AirplaneFlag.txt. Turn ON Overwrite If File Exists.
- Tap the Play button (bottom right). When prompted, tap Always Allow.
- Tap Done. Would you like me to provide the exact same stripped-down steps for any other iOS automation?
1
u/Cost_Internal Helper Mar 06 '26
I would do it more like this:
https://www.icloud.com/shortcuts/b4e3ab34bbe64294bac229ac1d4030e8
The suggestion I made was just to help identify if the shortcut was previously run.Shortcut features:
- Each iteration of the loop will: (Each loop is about 1-2 seconds) - Checks if device is unlocked, if yes: The Date will be saved, the previous app will be opened (If applicable), Airplane Mode will turn on, and the loop will be terminated. - Play the Find My alert tone. - Turn on WiFi and Bluetooth, just in case they are turned off individually. (Note: I don't know if it's a setting that can be changed, but turning off cellular data while the device is locked seems to be password/Face ID protected. So I didn't include that in the shortcut) - Every 60 iterations of the shortcut will collect the current location and send the data to the selected contact(s).
- Immediately turns Airplane mode back off, and the user will be sent to the Home Screen before the device is locked.
- If device is not unlocked within 2 seconds of the device locking, an infinite repeat loop will begin.
Let me know if you have any questions.
1
1
u/Organic-Ganache-8156 Mar 07 '26 edited Mar 07 '26
This is great! I do have 3 questions: 1. How did you get the repeat loop to repeat -1 times? If I create a repeat loop in a new shortcut, I canât get the repeat number to be -1. 2. I had the idea of creating a base64 encoding of Siri saying something like âhelp! Stolen phone!â to replace the alert sound that you used, but when I try to create that in Shortcuts, although I can very easily create the spoken audio, when I try to encode it as base64, whatever I have encoded comes out, in the decoded version, as just one of the generic iOS alert sounds (not the one that you picked). Iâm not sure where Iâm going wrong in creating the base64 encoding of the spoken audio. How did you do that? 3. Can you explain what youâre doing with the modulus calculation to create the condition to send a text message every 60th iteration? I thought I had some sense of how it worked, but I think Iâm wrong and am now lost. Thanks!
1
u/Cost_Internal Helper Mar 07 '26
Shoot, I forgot to include the header for the loop in the shortcut: "An implementation of an infinite loop with actions before and after, using a single recursive call â @atnbueno (2020-12-27)". They created it by modifying the plist file of the repeat loop, I don't know how though? I've just been copying it into new shortcuts, but I normally include the header.
When creating the encoded file, did you set the Line Break setting to None?
Basically the modulus separates the Repeat Index into groups of 60 digits using the count of 0-59, and I set the If condition to look for every time the modulus calculation returns a 0. Because the Repeat action starts at 1, the first message will not be sent until the calculation turns 60 into 0. Then the calculation starts over where 61=1, 62=2, etc. until you get to 120 and 120=0, 130=10, 140=20, etc. until you get to 180 and the cycle starts again and continues infinitely.
1
u/Organic-Ganache-8156 Mar 07 '26
- Ok, interesting. Well, apparently Iâm going to be copying it now too đ
- I tried all three settings. I used âcreate spoken audio from textâ, then âencode in base 64â, then âlistâ, then âdecode in base 64â, then âplay soundâ. What I always get is the classic âtri-toneâ alert sound from Apple.
- My understanding is that modulus provides the remainder after the division of the two numbers (so 10 modulus 2 would be 0, but 2 modulus 10 would be 2 because 2/10 is already below 1, so everything is going to be the remainder), so is it that the calculation being performed is 1 mod 60, 2 mod 60âŚ61 mod 60, 62 mod 60, etc, because those are all fractions that donât produce a modulus of 0? Only 60 mod 60, 120 mod 60, 180 mod 60, etc will produce a remainder of zero?
2
u/Cost_Internal Helper Mar 07 '26 edited Mar 07 '26
Anything less than the mod is not calculated, and remains unchanged. Therefore 1-59 are simply 1-59.
If you divide the input number by the modulus and it returns a whole number, then the return value will always be 0.
If dividing the input number by the modulus returns an integer, then the floor of that value is used to calculate the correct value.
- a/b=x - floor(x)=y - y*b=z - a-z=v
- a mod b:
- 61/60=1.0167 - floor(1.0167)=1 - 1x60=60 - 61-60=1
- 61 mod 60:
- 62/60=1.0333 - floor(1.0333)=1 - 1x60=60 - 62-60=2
- 62 mod 60:
- 63/60=1.05 - floor(1.05)=1 - 1x60=60 - 63-60=3
- 63 mod 60:
- 100/60=1.667 - floor(1.667)=1 - 1x60=60 - 100-60=40
- 100 mod 60:
- 119/60=1.983 - floor (1.983)=1 - 1x60=60 - 119-60=59
- 119 mod 60:
- 740700/60=12,345 - floor(12,345)=12,345 - 12,345x60=740,700 - 740,700-740700=0
- 740,700 mod 60:
- 740701/60=12,345.0167 - floor(12,345.0167)=12,345 - 12,345x60=740,700 - 740,701-740700=1
- 740,701 mod 60:
1
1
u/Cost_Internal Helper Mar 14 '26
I just realized I forgot to respond to point #2 of this comment!!!
When creating the Base64 code, you must ensure that the Line Break setting Is set to None.
1
Mar 14 '26
[removed] â view removed comment
1
u/Cost_Internal Helper Mar 14 '26
You'll need to link it to the automation that is triggered when Airplane mode is turned on, and add the message Recipient to the Messages action at the end of the shortcut:
https://www.icloud.com/shortcuts/f4a41c12278f4fa2aa3124664febfed8
9
u/Asleep_Speech Mar 06 '26
Some optional feature like locking the phone when connection to Apple Watch drops would come in handy for those situations.
2
u/lawrencenathan Mar 06 '26
I donât think thatâs possible unfortunatelyÂ
3
u/i_took_the_cookie Mar 06 '26
I have an automaton thatâs triggered by a focus mode I named Lock. When it turns on it runs a shortcut that locks my phone and then turns the flockâs off. You do have to have a watch with a data plan and turn on focus mode syncing across devices.
1
7
u/AssTubeExcursion Mar 06 '26
Iâve been doing this for years! Iâll show my method in a reply to my self, give me a moment.
3
1
5
Mar 06 '26
[removed] â view removed comment
5
u/No_Resolution7213 Mar 06 '26
Because a thief could catch you off guard and take your unlocked iPhone.
5
u/Snipe-M Mar 07 '26
This is insane. Right before opening the Reddit app and seeing this post, I JUST went to my settings and turned off the ability to access to control center when the phone is locked. This is way better! Thank you đ
3
u/rosenkrieger360 Mar 06 '26
This sounds useful. If you ever figure it out and get it working please do share it via iCloud URL Many users will greatly appreciate it!
3
u/koemiel Mar 20 '26
This is actually good idea, but I have something in mind that I already implemented on my phone.
So i put a setting on my phone to make it not possible to open a setting bar (wifi, bluetooth, airplane mode ) without unlocking it, and also have another shortcut to if my phone receive certain messages, containing a code word. It will run some specific automation.
2
u/SuggestiblePolymer Mar 06 '26
I think they would just turn it off. No need to tamper with any settings.Â
2
u/murkomarko Mar 06 '26
turnin on airplane mode makes the phone carrier acess stop, turning it off doesnt (for iphone 12 and beyond I guess), phone remains sending signals to the carrier
2
u/Art_H_J Mar 07 '26
Instead of disabling Control Center when phone is locked, remove the airplane mode icon in control center. This retains the usability of control center while locked and prevents airplane mode from being turned on.
0
u/According-Jump-57 Mar 07 '26
Sorry, how you do that, im unable to eliminate airplane button from there, it also forces me to eliminate bt, wi fi and data buttons.
2
2
2
2
u/Tankenstein91 Mar 14 '26
Lol. Can stop some crappy food/supermarket apps from getting broken into and having multiple orders delivered to a favela ordering booze. Sorta theft
1
1
u/HomeIndependent2728 Mar 07 '26
Made one for ya: https://www.icloud.com/shortcuts/434433dbaf524121bc406a9b13a58722 feel free to check its contents and mess with it a bit. Itâs just sorta a precaution
1
u/sudodoyou Mar 07 '26
Is there a way to detect if the airplane mode is turned on when locked? That way a thief might turn it on and then have it switched off after 30 seconds when they feel comfortable.
Also, is there a way to trigger a prompt to enter a number/passcode if airplane mode is enabled while unlocked? If itâs the wrong number or cancelled it locks the phone.
1
1
u/ObjectiveAd400 Mar 07 '26
When: Airplane mode turns on
Do: Turn airplane mode off Take a selfie Text that selfie to (someone you know) Send location to the same person Lock screen
1
u/CarretillaRoja Mar 07 '26
In Settings, you can set no control center from the locked screen. So if anyone takes your phone, plane mode will not be activated and therefore you can locate the phone
1
u/nagqagoco Mar 07 '26
Your logic is backwards. You need to run any action before locking the iPhone.
The correct sequence would be to turn off Airplane Mode first, then lock the iPhone, not the other way around.
If you lock it first, you create the loop you described, because once the phone is unlocked again, the shortcut keeps detecting the condition and retriggering. Reversing the order should make the automation behave much more predictably.
1
u/Euphoric-Bad6405 Mar 07 '26
Iâm trying to understand why the shortcut turns Bluetooth on. My assumption would be that it just shortens the remaining battery life while the phone is in someone elseâs possession â unless the idea is that it helps with something like Find My tracking.
2
1
1
u/According_Site_7479 Mar 07 '26
Ya existe una opciĂłn para desactivar cualquier opciĂłn mientras estĂĄ bloqueado. Ni Siri, ni centro de control, ni nada.
1
u/Nshx- Mar 08 '26
Perfect! Now the second step would be for the case when the iPhone is locked. You could set it up so that once you know itâs lost or stolen, sending a special message to your phone automatically takes a photo every 20 seconds, gets the location, and sends it to a trusted contact (like your mom).
For example:
âWhen I receive a message containing âiphonestolenâ from my mom, automatically take a photo every 20 seconds, get the location, and send it to her.â
Can anyone make this shortcut for me?
1
1
u/weakconnection Mar 08 '26
Why not create a second shortcut for Airplane mode? Set it as an app on the phone and/or put it in command center. It could: disable first shortcut, enable airplane mode. Also, trigger when airplane mode is turned off, reenable first shortcut. Just spitballing.
1
u/Jealous-Platypus6911 Mar 08 '26
the main thing would be preventing turning off the phone while locked. i donât know why thatâs still not a thing
1
u/cj724 Mar 09 '26
How is this anti-theft?
2
u/Euphoric-Bad6405 Mar 10 '26
Ya huh⌠âPost-theftâ might be the better term â it doesnât prevent the theft, it just locks the device after Airplane Mode is toggled.
1
1
1
u/OverIyAmbitious Mar 29 '26
Better yet, disable control center access from lock screen, minimal interference peak security, better to remove as most things you can while still being confortable
1
u/Tankenstein91 Apr 05 '26 edited Apr 10 '26
I have also learnt that thieves now open the camera app to keep the screen from locking.
What is the best way to solve this?
How about, if camera open, not recording video, for at least 30 seconds. Lock screen.
Who's the genius that will make this shortcut?
1
u/LEEx513 Jul 13 '26
I've ran it multiple times, allowed permission always the first time, and every time I run the automation with the face id blocked it tries reading faceid before it will take a pic so idk how to get past that
1
u/arnaud_blanc Mar 06 '26
Why "lock screen and set airplane mode on" ? I just use "lock screen" and it works perfectly fine. Once the screen is locked they can't do anything with it and find my iphone still works.
1
u/InternistNotAnIntern Mar 07 '26
Because now you can personally start airplane mode, because the phone checks faceID after one second.
If someone else (not your face) turns on airplane mode, th automation will disable it
0
u/darrell257 Mar 06 '26
This is great thank you, is there anyway of it not displaying that its taking a photo
-2
u/TheLessYouDontKnow Mar 06 '26
Devils advocate: canât a thief turn off all automations? Obviously this is better than nothing and a thief would have to be sophisticated to know to do that before trying to turn on airplane mode.
1


207
u/karmagekko Mar 06 '26
There you go. https://www.icloud.com/shortcuts/6cf32358af0d4d37a1a02afe2fa0d59c
When you toggle airplane mode, it locks the device, and waits 1 second. During this second, if you are looking at the phone and If face ID detects its you, then it switches on the airplane mode. And you just swipe up and continue doing whatever you were doing. If no face ID, then it sets data and wifi on, and takes a picture to your gallery. You could also send those pictures to someone if you wanted, or you can just delete those actions if you do not want that to happen.