推送通知中未播放声音 [英] Sound is not played in push notifications
问题描述
我正在使用iOS 7,但我的推送通知无法播放声音.
I am using iOS 7 and my push notifications do not play sounds.
奇怪的是,我发现我的应用程序的首选项">通知中心"中没有声音设置.以下是我的应用程序的通知中心的屏幕截图:
Strangely, I found there is no setting for sound in the Preference > Notification Center for my app. Following is the screenshots of Notification center for my app:
以下是Skype的内容:
And following is that for Skype:
您看到的是,我的应用程序没有声音"部分.
You see, there is no 'Sounds' section for my app.
有人可以帮忙吗?
更新:
现在我已经在我的应用程序中注册了声音.通知中心现在看起来像:
Now I have registered sound in my app. The Notification Center now looks like:
,并且我的通知有声音.看起来不错.
and my notification has sounds. Looks good.
但是,当我输入应用程序的设置后,最初有一个声音"部分,如Skype,但随后首选项"应用程序崩溃了,此后,不再有声音"部分,如下所示:
But after I enter the setting of my app, there is initially a 'Sounds' section like Skype, but then the Preference app crashed, and after that, there is no more 'Sounds', just like below:
可能是Apple的错误吗?
Might it be a bug of Apple?
推荐答案
您尚未在应用中注册音频推送通知.只需在您的应用程序委托中注册即可:
You're not registered for audio push notifications in your app. Just register for it like this in your 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
以下是文档:注册远程通知
希望有帮助!
这篇关于推送通知中未播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!