我正在尝试使用本地通知播放自定义 mp3 声音文件(10-25 秒)。我已将自定义声音文件放置在 iOS 项目文件夹中(与 Resources 同一级别),其中 BundleResource 作为 BuildAction。我还将声音文件放置在具有相同构建操作的资源文件夹中。看来两者都不起作用。
var content = new UNMutableNotificationContent
{
Title = title,
//Subtitle = "Notification Subtitle",
Body = body,
Badge = 1,
Sound = UNNotificationSound.GetSound("music.mp3"), //play custom sound
UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(id), NSObject.FromObject(notificationKey))
};
var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(10, false);
var requestID = "request_" + id;
var request = UNNotificationRequest.FromIdentifier(requestID, content, trigger);
UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
{
if (err != null)
{
throw new Exception($"Failed to schedule notification: {err}");
}
});
有什么建议吗?