[英]Sound is not played in push notifications
I am using iOS 7 and my push notifications do not play sounds. 我正在使用iOS 7,我的推送通知不播放声音。
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:
以下是我的应用程序通知中心的屏幕截图:
And following is that for Skype: 以下是Skype的内容:
You see, there is no 'Sounds' section for my app. 你看,我的应用程序没有“声音”部分。
Could anyone help? 有人可以帮忙吗?
Update: 更新:
Now I have registered sound in my app. 现在我在我的应用程序中注册了声音。 The Notification Center now looks like:
通知中心现在看起来像:
and my notification has sounds. 我的通知有声音。 Looks good.
看起来不错。
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: 但在我输入我的应用程序的设置后,最初有一个像“Skype”这样的“声音”部分,但随后Preference应用程序崩溃了,之后就没有“声音”,就像下面一样:
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:
只需在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;
}
The 5 types are: 这5种类型是:
Here's the documentation: Registering for Remote Notifications 这是文档: 注册远程通知
Hope that helps! 希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.