使用UILocalNotification将iPhone从睡眠模

使用UILocalNotification将iPhone从睡眠模

本文介绍了iBeacon检测使用UILocalNotification将iPhone从睡眠模式唤醒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在iOS 8上运行,当它进入后台时,需要检测并在检测到iBeacon时向用户显示通知(使用UILocalNotification)。

My application run on iOS 8 and when it go into background it need to detect and show a notification to the user when iBeacon detected (with UILocalNotification).

全部工作正常,但当iPhone处于睡眠/锁定时,通知不会唤醒设备。

All works fine but when the iPhone is sleep/locked the Notification doesn't wake up the device.

如何在收到通知时唤醒设备?

How can I wake up the device when a notification come in?

推荐答案

确保手机正在检测信标。尝试在 didEnterRegion 方法中或在启动通知的任何位置添加 NSLog 语句。然后,在手机屏幕关闭时开始查看调试控制台并打开信标。你有调试线吗?

Make sure the phone is detecting the beacon at all. Try adding a NSLog statement inside the didEnterRegion method or wherever you launch the notification. Then, start looking at the debug console while the phone screen is off and turn on the beacon. Do you get a debug line?

如果没有看到调试行,问题在于检测,而不是通知。请注意,在iPhone 4S上最多可能需要15分钟来检测信标。

If you do not see the debug line, the issue is with detection, not with the notification. Note that it can take up to 15 minutes on an iPhone 4S to detect a beacon.

如果这没有帮助,请发布设置区域监控和发送的代码通知。另外,请描述您如何测试进入和退出该地区。

If this does not help, please post your code that sets up region monitoring and sends the notification. Also, please, describe how you are testing entering and exiting the region.

这篇关于iBeacon检测使用UILocalNotification将iPhone从睡眠模式唤醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:08