【问题标题】:PushSharp iOS PushNotification with custom sound带有自定义声音的 PushSharp iOS PushNotification
【发布时间】:2013-08-20 08:56:30
【问题描述】:

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

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

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

我需要做什么才能让它工作? 是关于文件类型的吗?

【问题讨论】:

    标签: ios apple-push-notifications pushsharp


    【解决方案1】:

    我从未使用过 PushSharp,但向推送通知添加声音的正常方法是像您一样简单地指定完整的文件名。您确定声音名称正确且文件在应用中可用吗?

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

    +(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];
    }
    

    【讨论】:

    • 我刚试过 - 它适用于本地通知。那么可能是什么问题?我已经验证了名称。
    • 好吧,这可能是 PushSharp 的问题。您可以测试另一个推送服务提供商(例如 UrbanAirship - 我们对他们的服务非常满意。)
    • 嗯..当我在本地通知测试后再次尝试时,它工作了 - 也在其他设备上..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-13
    • 1970-01-01
    • 2019-09-14
    • 1970-01-01
    • 2017-03-10
    • 1970-01-01
    • 2014-04-15
    相关资源
    最近更新 更多