0.4 C
New York
Sunday, March 9, 2025

swiftui – Inside my iOS homescreen widget, how do I set off ios enter dialog (just like Shortcut’s Ask for enter textual content motion)?


enter picture description right here

TLDR I need consumer to have the ability to rapidly replace textual content standing throughout the residence display widget, with out the necessity to open my app, however undecided code it or if it even possilble.

Is it potential to in iOS 17/18 to set off a textual content area enter dialog after I tapped on my button inside my app’s residence display interactive widget? I have been on the lookout for options for nearly per week and looks like nothing works. I am sure it may very well be carried out as a result of after I’m utilizing the Shortcuts app residence widget (not simply add to residence icon bookmark), it may possibly instantly set off the textual content enter immediate overhead.

answer that I’ve tried is that I create an new appintents for this button to set off, the place contained in the intent I attempted:

```lang-swift

struct UpdateStatusIntent: AppIntent {
     static var title: LocalizedStringResource = "Replace Standing"
     static var description = IntentDescription("Replace your standing with customized textual content")
    
     @Parameter(title: "Standing Textual content", description: "The textual content to replace your standing with")
     var statusText: String
    
     init() {}
    
     init(statusText: String) {
         self.statusText = statusText
     }
    

     @MainActor
     func carry out() async throws -> some ReturnsValue {
         return .outcome(worth: statusText, dialog: IntentDialog(stringLiteral: "Standing up to date to: (statusText)"))
     }
    
 }

– above code works after I create App Shortcut utilizing that intent, it triggers the enter textual content dialog, however not after I faucet on my widget button.

– I additionally tried to make use of URL and x-callback-URL, however nonetheless nothing occurred after tapping the button. If I add a ‘print’ assertion contained in the carry out(), the print is exhibiting, however nothing occurs nonetheless.

above picture clarification: as you possibly can see I wish to open that enter textual content area when i faucet on the blue bell icon button, however I nonetheless cannot. The enter dialog is only for instance of what I need, and is triggered utilizing random Shortcut app Ask for enter button.

Actually respect any enlightment on this, thanks.

a few of my references documentation:

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles