为什么我的本地通知默认情况下在iOS 7中没有声音? [英] Why are my local notifications not having sound on by default in iOS 7?

查看:222
本文介绍了为什么我的本地通知默认情况下在iOS 7中没有声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用使用地理围栏并发送通知。

My app uses geofencing and sends a notification.

默认情况下,设置中的声音已关闭 - 该应用的通知。

By default, sounds are off in Settings - Notifications for the app.

确切地说是iOS 7。

iOS 7 to be precise.

有谁知道如何解决这个问题?

Does anyone know how to fix this?

以下是负责此操作的代码:

Here is the code responsible for this:

UILocalNotification *localNotif = [[UILocalNotification alloc] init];
        localNotif.fireDate = [NSDate dateWithTimeInterval:5 sinceDate:[NSDate date]];
        localNotif.timeZone = [NSTimeZone defaultTimeZone];
        localNotif.alertBody = [NSString stringWithFormat:@"You are near %@. Don't forget to check in!",place.name];
        localNotif.soundName = UILocalNotificationDefaultSoundName;
        localNotif.applicationIconBadgeNumber = 0;
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];


推荐答案

如果您的应用关闭了声音设置应用,然后您的通知将不播放任何声音。用户不允许你这样做。

If the sound is turned off for your app in the Settings app, then your notification will not play any sound. The user does not allow you to do that.

如果未在设置应用中关闭声音,那么您发布的代码应该有效。

If the sound is not turned off in the Settings app, that code that you posted should work.

此外,如果用户将铃声开关设定为关闭,则不会播放声音。

Also if the user set the ringer switch off, then there will be no sound played.

这篇关于为什么我的本地通知默认情况下在iOS 7中没有声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆