我使用的是 iOS 7,我的推送通知不播放声音。
奇怪的是,我发现我的应用程序的首选项 > 通知中心没有声音设置。以下是我的应用程序通知中心的屏幕截图:
下面是Skype的:
你看,我的应用程序没有“声音”部分。
有人能帮忙吗?
更新:
现在我已经在我的应用程序中注册了声音。通知中心现在看起来像:
我的通知有声音。看起来不错。
但是在我进入我的应用程序设置后,最初有一个像 Skype 一样的“声音”部分,但是后来 Preference 应用程序崩溃了,之后就没有更多的“声音”了,就像下面这样:
会不会是苹果的bug?
最佳答案
您没有在您的应用程序中注册音频推送通知。只需在您的 App Delegate 中像这样注册它:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Whatever you have already in your app delegate...
// Let device know you're going to be sending one of these types of notifications.
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
return YES;
}
这 5 种类型是:
- UIRemoteNotificationTypeBadge
- UIRemoteNotificationTypeSound
- UIRemoteNotificationTypeAlert
- UIRemoteNotificationTypeNone
- UIRemoteNotificationTypeNewsstandContentAvailability
这是文档:Registering for Remote Notifications
希望对您有所帮助!
关于ios - 推送通知中不播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20849566/