Swift 发布时将音频文件添加到捆绑包
Swift add audio files to bundle when released
最近我遇到了苹果的开发者限制。正如我所读,您不能使用捆绑包之外的自定义通知声音。
soundName Property
For this property, specify the filename (including extension) of a
sound resource in the app’s main bundle or
UILocalNotificationDefaultSoundName to request the default system
sound. When the system displays an alert for a local notification or
badges an app icon, it plays this sound. The default value is nil (no
sound). Sounds that last longer than 30 seconds are not supported. If
you specify a file with a sound that plays over 30 seconds, the
default sound is played instead.
但我们想要做的是录制一些音频文件并将其用作通知声音。我们已经将录音限制设置为 30 秒,因此它可用于通知声音。
有什么方法可以用这个自定义的录音作为通知音吗? (这实际上是我们的关键概念,所以如果这不起作用,我们的想法就会失败哈哈)
我已经浏览了几个主题,但它们都很老旧,所以我希望有人能找到新的 swift 之类的方法。
简答:这是不可能的。
由于代码签名概念——整个包都被签名以防止突变——你不能在运行时将文件添加到应用程序的主包。
最近我遇到了苹果的开发者限制。正如我所读,您不能使用捆绑包之外的自定义通知声音。
soundName Property
For this property, specify the filename (including extension) of a sound resource in the app’s main bundle or UILocalNotificationDefaultSoundName to request the default system sound. When the system displays an alert for a local notification or badges an app icon, it plays this sound. The default value is nil (no sound). Sounds that last longer than 30 seconds are not supported. If you specify a file with a sound that plays over 30 seconds, the default sound is played instead.
但我们想要做的是录制一些音频文件并将其用作通知声音。我们已经将录音限制设置为 30 秒,因此它可用于通知声音。
有什么方法可以用这个自定义的录音作为通知音吗? (这实际上是我们的关键概念,所以如果这不起作用,我们的想法就会失败哈哈)
我已经浏览了几个主题,但它们都很老旧,所以我希望有人能找到新的 swift 之类的方法。
简答:这是不可能的。
由于代码签名概念——整个包都被签名以防止突变——你不能在运行时将文件添加到应用程序的主包。