Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
Hello everyone,

I would like to know the frame to follow to do automation with IS on IOS 15 like:

-If airplane mode is enabled = stop the shortcut

-If cellular data OR wifi is enabled = stop the shortcut

-If cellular data OR wifi is disabled = Enabled cellular data AND wifi

-Wait 30 seconds

-Cut cellular data AND wifi

I'm really not very good at scripting, if you have an idea of how to follow it would be great

Have a good evening :)
 
  • Like
Reactions: Javi74

Taz Mangus

macrumors 604
Mar 10, 2011
7,815
3,504
The script would be:

Code:
Get current IP address

If Current IP address does not have have any value
    Turn Cellular Data On
    Turn Wi-Fi On
    Wait 30 seconds
    Turn Cellular Data Off
    Turn Wi-Fi Off
End If
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
Thank you for your answer, but I can't find a way to put the variable with my IP address and even the code itself does not fully meet the need in terms of airplane mode and Wi-Fi activated.
I want to create automation every hour that allows me to turn on my cellular data and Wi-Fi automatically to retrieve my notifications, but my automations must not cut me off when I use my phone to watch youtube for example.
My first msg script is exactly what I want but I don't know if it's possible to create it in shortcut...
 

now i see it

macrumors G4
Jan 2, 2002
11,239
24,220
Shortcut scripts are extremely limited. If you can’t see what you want to do in the shortcuts app, then it most likely can’t be done.
Just by looking at your requirements, my first thought is no way.
 

Taz Mangus

macrumors 604
Mar 10, 2011
7,815
3,504
Thank you for your answer, but I can't find a way to put the variable with my IP address and even the code itself does not fully meet the need in terms of airplane mode and Wi-Fi activated.
I want to create automation every hour that allows me to turn on my cellular data and Wi-Fi automatically to retrieve my notifications, but my automations must not cut me off when I use my phone to watch youtube for example.
My first msg script is exactly what I want but I don't know if it's possible to create it in shortcut...
There is no current way, in Shortcuts, to status whether Airplane mode is off or on. The only possible way to do it is to Turn Wi-Fi Off and then check to see if you are still getting an IP address. Also, keep in mind that the cellular IP address can change every time that you turn off and on cellular data. So if you are thinking of using a hard coded cellular IP address, it won't be very useful.

This is how you would set a variable with an IP address:
Code:
Text 172.58.122.19
Set variable myIPaddress to Text
What you want to achieve is not possible with the current Shortcuts commands in iOS 15. My suggestion is for you to leave feedback with Apple on adding new commands to Shortcuts.
 

NoBoMac

Moderator
Staff member
Jul 1, 2014
6,244
4,931
You can check to see if connected to wifi fairly easily.

Code:
Action "Get Network Details": Get Wi-fi Network's Network Name

if Name contains anything
-- do connected to wifi stuff
otherwise
-- do not connected to wifi stuff
end

There is an Automation for "when Airplane Mode (AM) turns on/off". Can leverage that to write a file to Files app's "On My" location that contains a "flag":
  • Automation for AM turns on: write file with "on" flag to Files
  • Automation for AM turns off: write new version of file with flag to "off" (or delete the file)
  • Check flag: read in file, check flag value to determine if AM on or off (or check for existence)
But this is not really needed, imo, as even in AM, you could have a wifi connection.

What @Taz Mangus posted in #2 is the check for "if connected to wifi or cellular", just make "has any value".

So:

Code:
Get IP address
if address has any value
    stop shortcut
otherwise
    turn on wifi/cellular
    do stuff
    turn off wifi/cellular
end
 

Taz Mangus

macrumors 604
Mar 10, 2011
7,815
3,504
There is actually a way to accomplish what you want to do using a combination of 2 Automation Shortcuts and a Shortcuts script. @NoBoMac made a good point that I had forgotten about.

First create your Shortcuts script. For example, your script might be named DoNetwork:
Code:
Receive Text Input from Nowhere

Text True
Set variable On to text Type Boolean

Set variable AirplaneMode to Shortcut Input Type Boolean

if AirplaneMode is On
    Turn Cellular Data On
    Turn Wi-Fi On
    Wait 30 seconds
    Turn Cellular Data Off
    Turn Wi-Fi Off
Otherwise
. . .
End If

Next create 2 Personal Automations:
Code:
When Airplane Mode is turned on

Do
Text True
Run DoNetwork Input Text Type Boolean
Code:
When Airplane Mode is turned off

Do
Text False
Run DoNetwork Input Text Type Boolean
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
Thank you for helping me guys! I just have a little question about the script, how do I edit it exactly? What function do I have to launch? I'm really a novice, if you know a tutorial it would be great :)
 

Taz Mangus

macrumors 604
Mar 10, 2011
7,815
3,504
Thank you for helping me guys! I just have a little question about the script, how do I edit it exactly? What function do I have to launch? I'm really a novice, if you know a tutorial it would be great :)
The Automations happen automatically once you enable them. When you create the Automation there is a "Enable This Automation" button that you use to enable it to run.

You can add a Shortcut to your Home Screen and when you want to manually run the script, you click on it as it will look like an application that you can run. In other words, you can manually run the Shortcut like any other application once you add it to your Home Screen. Or you can manually run the Shortcut directly from the Shortcuts application.
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
I expressed myself badly, I wanted to know how to write the script in my shortcut, not launch it, I need a third-party application to code or which modules to use exactly, that was my real question
 

Taz Mangus

macrumors 604
Mar 10, 2011
7,815
3,504
I expressed myself badly, I wanted to know how to write the script in my shortcut, not launch it, I need a third-party application to code or which modules to use exactly, that was my real question
Open the Shortcuts application and you create/edit/delete the shortcut script directly from the Shortcuts application.
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
I'm really sorry but I have a French version of shortcuts and I feel like I can't launch a script feature to edit code text, could you show me a concrete example, I can't find much on YouTube to help me
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
CB59D56E-995F-4233-B164-81A9C5D8787B.png
 

Attachments

  • FD32BFB9-8044-4137-9A1D-7D332BF05C31.png
    FD32BFB9-8044-4137-9A1D-7D332BF05C31.png
    353.9 KB · Views: 117

Taz Mangus

macrumors 604
Mar 10, 2011
7,815
3,504
You can test out the shortcut when it is being edited by pressing the play button located at the bottom right corner of the edit window. When you are done editing, click on the X located in the upper right hand corner of the edited window.
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
Okay, thank you very much but I don't know how to nest my variables... I don't know how to write my script, the modules to use, the function If... I'm lost in the method to follow could you show me an example?
I would be very grateful
 

Taz Mangus

macrumors 604
Mar 10, 2011
7,815
3,504
Okay, thank you very much but I don't know how to nest my variables... I don't know how to write my script, the modules to use, the function If... I'm lost in the method to follow could you show me an example?
I would be very grateful
From your post #13 it looks like you were able to create a Shortcuts..
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
Yes, I know how to create it but then I don't really understand how to nest my functions with each other...
 

SkippyR

macrumors newbie
Original poster
Jul 1, 2022
10
1
After several attempts I finally understood, guys you're really crazy!!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.