Thursday, May 8, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

Creating Shortcuts with App Intents

October 2, 2023
in Cloud & Programming
Reading Time: 3 mins read
0 0
A A
0
Share on FacebookShare on Twitter



Adding support for shortcuts can be a great way to enhance your app and integrate it seamlessly into the iOS ecosystem. Shortcuts allow users to interact with your app without having to navigate through specific screens. They can be executed through voice commands, text inputs, or even Spotlight search. Users can also create workflows by combining multiple shortcuts to accomplish multiple tasks at once.

In the past, adding shortcuts to your app and making them accessible to the system was a complex and time-consuming process. You had to use visual editors and map code files to Intent Definition files. However, with the introduction of iOS 16, Apple has revamped the process using the new App Intents framework. Now, you can create shortcuts directly in Swift, without the need for additional steps or code generation. These shortcuts are immediately available to users through Siri, the Shortcuts app, and Spotlight.

To get started, download the starter project and open it in Xcode. The project is called BreakLogger and it allows users to record break times throughout the day. Build and run the app, and you’ll see an empty break list. Tap the “Add” button to record a break. You can select a break duration from the options provided. After adding a break, it will appear in the break list.

Currently, the only way to log a break is through the app itself. However, iOS offers other ways to interact with apps in its ecosystem. Users might want to log a break as part of a larger workflow or ask Siri to log a break without opening the app. By integrating the App Intents framework into your app, you can enable these use cases.

To define your first app intent, right-click on the Source group in your project and create a new group called “Intents”. Inside this group, create a new Swift file named “LogBreakIntent.swift”. In this file, create a struct called “LogBreakIntent” that conforms to the AppIntent protocol. This struct will represent your shortcut. Add a static property called “title” to provide a localized title for your shortcut. Then, implement the “perform()” function to perform the desired action when the shortcut is executed. In this case, it logs a 15-minute break using the LoggerManager and returns a dialog message indicating that the break has been logged.

With the LogBreakIntent defined, users can create a shortcut using this intent. Build and run the app to install it on the simulator. Then, open the Shortcuts app and create a new shortcut. Select the “Apps” category and choose BreakLogger. Add the “Log a Break” action to your shortcut. After saving the shortcut, you can run it by tapping on it. A dialog message will appear, confirming that the break has been logged. When you reopen the BreakLogger app, you’ll see the logged break in the list.

Next, you’ll add an app shortcut to BreakLogger. Create a new Swift file named “BreakLoggerShortcuts.swift” in the Intents group. In this file, create a struct called “BreakLoggerShortcuts” that conforms to the AppShortcutsProvider protocol. This struct will provide the app shortcuts to iOS. Implement the static property “appShortcuts” to return an array of AppShortcut instances. For this example, you’ll only provide one shortcut, which uses the LogBreakIntent and has two phrases that can trigger it. One phrase is “Log a break” and the other uses the special token “.applicationName” to dynamically insert the localized name of your app.

Build and run the app again. This time, you can use Siri on the simulator to trigger the shortcut by saying “Use BreakLogger to log a break”. Siri will prompt you to enable BreakLogger shortcuts and then confirm the action. When you open BreakLogger, you’ll see the break logged from the shortcut in the list.

In the next step, you’ll create a custom confirmation view to display whenever the intent is executed.



Source link

Tags: AppCreatingIntentsShortcuts
Previous Post

SHAP vs. ALE for Feature Interactions: Understanding Conflicting Results | by Valerie Carey | Oct, 2023

Next Post

Tesla owners must arbitrate false advertising claims over autopilot feature- ruling By Reuters

Related Posts

Top 20 Javascript Libraries You Should Know in 2024
Cloud & Programming

Top 20 Javascript Libraries You Should Know in 2024

June 10, 2024
Simplify risk and compliance assessments with the new common control library in AWS Audit Manager
Cloud & Programming

Simplify risk and compliance assessments with the new common control library in AWS Audit Manager

June 6, 2024
Simplify Regular Expressions with RegExpBuilderJS
Cloud & Programming

Simplify Regular Expressions with RegExpBuilderJS

June 6, 2024
How to learn data visualization to accelerate your career
Cloud & Programming

How to learn data visualization to accelerate your career

June 6, 2024
BitTitan Announces Seasoned Tech Leader Aaron Wadsworth as General Manager
Cloud & Programming

BitTitan Announces Seasoned Tech Leader Aaron Wadsworth as General Manager

June 6, 2024
Copilot Studio turns to AI-powered workflows
Cloud & Programming

Copilot Studio turns to AI-powered workflows

June 6, 2024
Next Post
Tesla owners must arbitrate false advertising claims over autopilot feature- ruling By Reuters

Tesla owners must arbitrate false advertising claims over autopilot feature- ruling By Reuters

Amazon’s Bedrock and Titan Generative AI Services Enter General Availability

Amazon's Bedrock and Titan Generative AI Services Enter General Availability

Hot takes in IO: 3 potential pitfalls of NYC Local Law 144

Hot takes in IO: 3 potential pitfalls of NYC Local Law 144

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
Porfo: Revolutionizing the Crypto Wallet Landscape

Porfo: Revolutionizing the Crypto Wallet Landscape

October 9, 2023
A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

May 19, 2024
A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

April 10, 2024
Part 1: ABAP RESTful Application Programming Model (RAP) – Introduction

Part 1: ABAP RESTful Application Programming Model (RAP) – Introduction

November 20, 2023
Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

December 6, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In