具有自定义声音的PushSharp iOS PushNotification(PushSharp iOS PushNotification with custom sound)

编程入门 行业动态 更新时间:2024-10-28 10:25:07
具有自定义声音的PushSharp iOS PushNotification(PushSharp iOS PushNotification with custom sound)

我正在尝试使用PushSharp在推送通知中添加自定义声音,但我找不到任何关于此的文档。 我在C#中使用Windows服务,并且每个东西都使用默认声音。 但是当我使用这段代码时,我要么得到默认声音,要么没有声音。

push.QueueNotification(new AppleNotification() .ForDeviceToken(deviceToken) .WithAlert(FormatMatchesMessage(offers)) .WithSound("Jingle.mp3"));

我有声音文件包含在C#项目中,也包含在iOS应用程序项目中。

我需要做些什么来使它工作? 它是关于文件类型的吗?

I am trying to add a custom sound to at push notification with PushSharp, but I can't find any documentation about this. I am using a windows service in C#, and every thing worked with default sound. But when I use this code I either get default sound og no sound.

push.QueueNotification(new AppleNotification() .ForDeviceToken(deviceToken) .WithAlert(FormatMatchesMessage(offers)) .WithSound("Jingle.mp3"));

I have the sound file included in the C# project, and also included in the iOS app project.

What do I need to do to make it work? Is it something about filetypes?

最满意答案

我从未使用过PushSharp,但是向Push通知添加声音的常规方法是简单地指定完整的文件名,就像你一样。 您确定声音名称是否正确并且该文件在应用程序中可用?

您可以通过调用以下方法尝试使用声音安排本地推送通知:

+(void)scheduleNotificationForDate:(NSDate*)date withMessage:(NSString*)message andOKButtonTitle:(NSString*)buttonTitle andPayLoad:(NSMutableDictionary*)dic andSoundName:(NSString*)soundName { UILocalNotification *not =[[UILocalNotification alloc] init]; not.fireDate = date; not.alertBody = message; not.alertAction = buttonTitle; not.soundName = soundName; [[UIApplication sharedApplication] scheduleLocalNotification:not]; }

I have never used PushSharp, but the normal way of adding sounds to Push notification is to simple specify the full filename, as you do. Are you sure the sound name is correct and the file is available in the app?

You can try scheduling a local push notification with the sound by calling a method like:

+(void)scheduleNotificationForDate:(NSDate*)date withMessage:(NSString*)message andOKButtonTitle:(NSString*)buttonTitle andPayLoad:(NSMutableDictionary*)dic andSoundName:(NSString*)soundName { UILocalNotification *not =[[UILocalNotification alloc] init]; not.fireDate = date; not.alertBody = message; not.alertAction = buttonTitle; not.soundName = soundName; [[UIApplication sharedApplication] scheduleLocalNotification:not]; }

更多推荐

本文发布于:2023-08-07 10:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463345.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   声音   PushSharp   iOS   custom

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!