ios 配置快捷指令

js 复制代码
struct OpenIntent: AppIntent {
    @available(iOS 16, *)
    static var title = LocalizedStringResource("这里填写标题")
    @available(iOS 16.0, *)
    static var description = IntentDescription("这里填写描述")
    
    // 意图执行时,是否自动将应用拉起到前台
    static var openAppWhenRun: Bool = true
    
    @available(iOS 16.0, *)
    func perform() async throws -> some IntentResult {
        //这样写会有一个dialog提示
//        return .result(dialog: "play")
  //这样写没有弹窗
        return .result()
    }
}

struct MeditationShortcuts: AppShortcutsProvider {
  
    @available(iOS 16.0, *)
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: OpenIntent(),
            phrases: [
                "\(.applicationName) aaa",//这里必须有\(.applicationName) 否则在快捷指令里面搜索不到
            ],
            //shortTitle 跟 systemImageName 最好一起写
            shortTitle: "charge",
            systemImageName: "battery.100percent.bolt" 
        );
        
    }
}

设置systemImageName 的颜色以及在快捷指令中显示的背景色

info.plist 中添加

CustomTintColor BackgroundGradientColor1 BackgroundGradientColor2 都是设置的颜色资源的名字

xml 复制代码
<dict>
     <key>CFBundlePrimaryIcon</key>
     <dict>
         <key>NSAppIconActionTintColorName</key>
         <string>CustomTintColor</string>
         <key>NSAppIconComplementingColorNames</key>
         <array>
             <string>BackgroundGradientColor1</string>
             <string>BackgroundGradientColor2</string>
         </array>
    </dict>
</dict>
相关推荐
weixin_452093251 小时前
关于apple ios苹果mdm监管锁的漏洞与修复
ios
明似水5 小时前
Flutter iOS 项目中 VolumeControllerPlugin 报错解决方案
flutter·ios
lilili啊啊啊7 小时前
怎么查看苹果手机和ipad的设备信息和ios udid
ios·智能手机·ipad
依旧风轻16 小时前
深入理解 rsync daemon 模式(守护进程)
linux·ios·rsync·daemon·sqi
leluckys18 小时前
swift-oc和swift block和代理
开发语言·ios·swift
测试萧十一郎20 小时前
APP测试中ios和androis的区别,有哪些注意点
自动化测试·软件测试·功能测试·macos·ios·职场和发展·cocoa
鸿蒙布道师1 天前
鸿蒙NEXT开发全局异常捕获与崩溃日志收集工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
鸿蒙布道师1 天前
鸿蒙NEXT开发节流、防抖工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
依旧风轻1 天前
深入解析 Jenkins Agent 的 .jnlp 启动文件
运维·ios·jenkins·agent·slave
leonyie20221 天前
7.3 在通知中显示图片或视频(UNNotificationAttachment)
macos·ios·swiftui·音视频·cocoa·swift