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>
相关推荐
北京自在科技3 小时前
苹果iOS 26.3实现跨安卓数据无缝迁移
android·ios·findmy
郑梓斌6 小时前
Luban 2 Flutter:一行代码在 Flutter 开发中实现图片压缩功能
flutter·ios
遥不可及zzz9 小时前
ios adjust Google 设备端转化衡量
ios
酒醉的胡铁12 小时前
uniapp解决video组件在ios上全屏页面旋转90度,组件旋转180度
ios·uni-app
张飞签名上架14 小时前
深度解析超级签:iOS 应用分发的便捷之选与风险权衡
ios·苹果签名·企业签名·苹果超级签名·tf签
2501_9159184114 小时前
iOS App的tcp、udp数据包抓取在实际开发中的使用方式
android·tcp/ip·ios·小程序·udp·uni-app·iphone
2501_9159090616 小时前
iOS 应用在混淆或修改后,如何完成签名、重签名与安装测试
android·ios·小程序·https·uni-app·iphone·webview
Digitally19 小时前
如何顺利地将手机号码转移到新iPhone
ios·iphone
茅根竹蔗水__1 天前
iOS应用(App)生命周期、视图控制器(UIViewController)生命周期和视图(UIView)生命周期
ios