4

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 :)

pawello2222
  • 46,897
  • 22
  • 145
  • 209
Rebar
  • 1,076
  • 10
  • 19

1 Answers1

2

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.

pawello2222
  • 46,897
  • 22
  • 145
  • 209
  • 1
    thanks for information, but in this case Widget are just dummy thing and we cannot do much with them, I had so hope about them but it is useless, for example a user just want play/pause something therefore it must open app through Widget! I am going give a good time to Widget and Apple to make them at least some more usable – ios coder Feb 03 '21 at 00:18
  • 1
    @swiftPunk That's just how Apple designed the widgets. They are not *mini-apps* but rather only provide glanceable information. I suggest you take a look at https://developer.apple.com/documentation/widgetkit – pawello2222 Feb 03 '21 at 00:21
  • @pawello2222 but that's exactly where we developers and UX-designers have to give them the feedback, that this is a step backwards! We can't just say: it's like that and we can't to do anything just because it's "Apple" – Rebar Apr 29 '21 at 10:23