Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

flutter - How to prevent iOS 14 Widget opening app and react to callback

So, I already read several blogs, posts, and Apple's own Human Interface Guidelines that iOS 14 Widgets are NOT interactive, BUT: It's possible to pass a short link to the app when pressing on a target. Apple on its own says: "Small Widgets got one single tap target, Medium and Large Widgets got multiple tap targets". OK!

Now when you tap on these Targets the app is opening and the Widget is passing that short link to the App.

BUT, now my question, where Google says Idk:

Can I programmatically say "prevent opening app", when tapping on one of these buttons I've created in my Widget? It's just as easy as in Javascript: preventDefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault).

Is this possible? I just want to prevent the opening of the app and access that Tap-Target Callback that is triggered and process my stuff in SwiftUI.

Thanks a lot, guys :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Can I programmatically say "prevent opening app", when tapping on one of these buttons I've created in my Widget?

No, this is simply not possible (at least so far, in iOS 14).

By default whenever you tap on a Widget, the App will be opened. You can only specify deep links etc. but they'll always open the app.


I already read [...] that iOS 14 Widgets are NOT interactive

In this context interactive means that you can't touch/drag/interact with a Widget view like you'd normally do with a view in your main app (see Why do some views appear as a red no entry sign in widgets?).

Also, when you click on a Widget, you don't really interact with its view - you just open the app. As of iOS 14 you can't change it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...