gpt4 book ai didi

ios - 推送通知 : no sound

转载 作者:搜寻专家 更新时间:2023-10-30 22:14:23 27 4
gpt4 key购买 nike

我已经使用 Parse.com 在我的应用程序中实现了推送通知系统,一切正常!

我唯一的问题是当通知到达时:它不播放任何声音!

我进入设置(在我的平板电脑中),在通知下,我看到了这个:

enter image description here

如您所见,“声音”和“角标(Badge)”已关闭。如果我打开它们,那么当推送通知到达时:它会播放声音!

所以...我希望当我安装我的应用程序时,这两个选项默认为 TRUE。

这可能吗?我该怎么做?

我在 Swift 工作,这是我目前的代码:

方法 didFinishLaunchingWithOptions

 var pushSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge , categories: nil)
application.registerUserNotificationSettings(pushSettings)
application.registerForRemoteNotifications()

非常感谢你帮助我

最佳答案

UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, categories: nil))

你还必须设置声音名称,因为默认是没有声音的:

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.

yourNotification.soundName = UILocalNotificationDefaultSoundName

soundName

对于您需要使用的远程通知 The Notification Payload

关于ios - 推送通知 : no sound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27815909/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com