UILocalNotification无法正常工作... iPhone 4 iOS 4.3上没有振动 [英] UILocalNotification Not Working ... No Vibration on iPhone 4 iOS 4.3

查看:66
本文介绍了UILocalNotification无法正常工作... iPhone 4 iOS 4.3上没有振动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会写尽可能多的内容,但标题几乎说明了一切.我已经在几种不同的情况下对其进行了测试:

I would write as much as I could write here, but the Title pretty much says it all. I've tested it in several different situations:

我知道这通过应用程序委托的didReceiveLocalNotification进行,并且没有声音或振动,除了我在didReceiveLocalNotification下包含的处理代码之外.实际称为

I know that this goes through app delegate's didReceiveLocalNotification and didn't expect a sound or vibration, except for the handling code that I included under didReceiveLocalNotification. The handling code actually called

        NSURL *Sound   = [[NSBundle mainBundle] URLForResource: self.currentSoundPVC
                                    withExtension: @"caf"];
        // Create a system sound object representing the sound file.
        AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject);
        AudioServicesPlayAlertSound (soundFileObject);

这确实有效!它会播放声音并同时振动手机.

and that actually works! It plays a sound and vibrates the phone simultaneously.

现在,我使用以下代码在应用程序委托的applicationDidEnterBackground中设置uilocalnotification警报

Now, I set up my uilocalnotification alarms in app delegate's applicationDidEnterBackground, using the following code

NSString *Sound   = [self.currentSoundPVC stringByAppendingString:@".caf"];
UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
alarm.fireDate = [NSDate dateWithTimeIntervalSinceNow:seconds];
[alarm setSoundName:Sound];
[[UIApplication sharedApplication] scheduleLocalNotification:alarm];

,这仅部分起作用!声音被播放,但是没有振动!现在,我认为这是一个错误,因为我是从Apple开发人员网站

and this only partially works! The sound gets played but there is NO VIBRATION! Now, this I think is a bug because I am quoting from the apple developer website,

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html ,计划本地通知的发送"部分:

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html, Scheduling the Delivery of Local Notifications section:

发送通知并播放声音时,系统还会在支持该通知的设备上触发振动."

"When the notification is sent and the sound is played, the system also triggers a vibration on devices that support it. "

现在,很明显,这不是我的iPhone的情况,而且模拟器显然没有振动,因此我无法对其进行测试,并希望在开发人员社区中解决此问题!

Now, obviously that is NOT THE CASE for my iPhone and obviously the simulator doesn't vibrate, so I can't test this and would like to have this addressed in the developer community!

与#2相同

与#2相同

与#2相同,因为uilocalnotifications从未被取消,因此iOS仍然认为它们是有效的.

Same as #2, because the uilocalnotifications were never cancelled, so the iOS still thinks they are valid.

没有声音,没有振动,什么都没有!糟透了!我本来希望苹果能像往常一样直接开箱即用!

no sound, no vibration, NOTHING! This sucks! I would have hoped that apple would have come up with something that works straight out of the box, as usual!

推荐答案

这些是选项和效果(均假定音量设置为某个合理的值):

These are the options and the effects (all assume the volume is set to some reasonable value):

配置:

  • [由开发人员控制]在UILocalNotification中设置的有效声音名称=否
  • 该应用的[用户控制]通知中心设置:声音=不适用
  • [用户控制]静默模式(iPhone侧面的开关)= N/A

行为:

  • 发出通知时声音=否
  • 以通知=否振动

配置:

  • 在UILocalNotification中设置的有效声音名称=是
  • 该应用程序的通知中心设置:声音" =关闭"
  • 静音模式(iPhone侧面的开关)= N/A

行为:

  • 发出通知时声音=否
  • 以通知=否振动

配置:

  • 在UILocalNotification中设置的有效声音名称=是
  • 应用程序的通知中心设置:声音=开"
  • 静音模式(iPhone侧面的开关)=否(未选择)

行为:

  • 发出通知时发出的声音=是
  • 以通知=否振动

配置:

  • 在UILocalNotification中设置的有效声音名称=是
  • 应用程序的通知中心设置:声音=开"
  • 静音模式(在iPhone侧面打开)=是(已选择)

行为:

  • 发出通知时声音=否
  • 通过通知振动=是

这篇关于UILocalNotification无法正常工作... iPhone 4 iOS 4.3上没有振动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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