r/swift • u/Extreme-Baby3813 • Jul 19 '25
how does the app "one sec" do it
One sec uses an app intent that occurs when, for example, tiktok is opened. You are routed to one sec and you do the intervention, and then you are routed to tiktok. When you are routed to tiktok, the app intent runs again. But this time the app intent doesn't route you to one sec. How is that possible? TLDR: how is an app intent able to dynamically decide if it should open its app?
Issues I ran into:
- setting "openAppWhenRun" to true causes the app to be opened everytime the action is run
- Opening the app through url scheme causes a security error: "Request is not trusted."
Specs:
- tested on personal iphone 16 pro (iOS 18.5)
- xcode 16.2
- swift 5

3
u/ExtinctedPanda Jul 19 '25 edited Jul 19 '25
Can’t you just keep track of the last time at which your app intent opened the original app, and if it’s been a very brief time, don’t do anything?
2
u/sirlantis Jul 19 '25
I would assume they used the ForegroundContinuableIntent API. Note that it's now deprecated and you should declare support for dynamic foreground mode instead.
1
u/Away_Ad9128 Dec 08 '25
Im trying to build the same kind of feature but just using AI (im not a developer) but ive been running into issues. Some guidance would be amazing.
1
u/LavaCreeperBOSSB Learning Jul 19 '25
I guess they store a variable that says "if intervention done, don't open app, else open app"?
1
u/Less_Bumblebee8182 Aug 11 '26
For older iOS the intents route takes you only half way. user-created shortcuts automations ('when instagram opens') do run without confirmation since 17, which is how one sec classically did it, but the user has to set one up per app by hand. What you can't do pre-26 is drive that flow programmatically from your own app. hit this exact wall myself building a screen time app. You get the confirmation sheet or the trust eror and there's no flag that turns it off, it's not a config problem.
the other way to do this is FamilyControls, not intents. you shield the app through ManagedSettings and the system draws over it at launch, no shortcuts automation, no url scheme, nothing to loop back into, button taps get handled in a ShieldActionDelegate
two catches before you go down that road...you need the Family Controls distribution entitlement from Apple, which is a request form and not instant. And the shield UI is a fixed layout, title subtitle icon and two buttons, you can't drop an arbitrary swiftui view in there. that's probably why one sec strayed on the shortcuts side, they wanted the full custom screen
so it's pick your constraint, shortcuts gets you any UI you want but the user has to wire up every app themselves, family controls works everywhere with no setup on their end and the intervention has to fit apple's box