I'm planning to create a life saving application, and I need to integrate with any of the physical buttons on the iPhone (Home, volume, lock). Is this possible programmatically when the screen is off (on a non jail-broken device)?
我计划创建一个救生应用程序,我需要集成iPhone上的任何物理按钮(Home, volume, lock)。当屏幕关闭(在非破解设备上)时,这是否可以通过编程方式实现?
Thanks in advance!
提前谢谢!
4 个解决方案
#1
2
I like your idea, but I don't think that this will be obtainable on a non-jailbroken device. @Andrews answer could work if your app was triggered by a combination of play/pause, next and back but would require that your app was always the responder to the devices audio controls which is only possible between the time when the user closes your app, and launches anything else that takes control of device audio. (which probably wouldn't be that long)
我喜欢你的想法,但我不认为这能在非越狱设备上实现。@Andrews回答可以如果你的应用程序是由播放/暂停、下一个,但是需要你的应用总是响应方之间的设备音频控制这只可能在用户关闭应用程序,并启动其他音频需要控制的设备。(可能不会那么久)
Assuming that this would be the iOS version of Life Alert, that would dial emergency services for the user, it would be too difficult to keep the app from generating false positives and calling 911 every time the phone had a few buttons pressed in a pocket, purse, etc. Whereas with a jailbreak it may be possible to listen to a pattern (eg. home button- press, press, hold, press, press)
假设这是生命的iOS版本警报,这将为用户拨打紧急服务,这将是难以阻止应用程序产生假阳性和每次拨打911电话在口袋里有几个按钮按下,钱包等。而一个越狱可以听一个模式(如。home键-按,按,按住,按,按)
On top of this attempting to use anything on the lock screen for something other than its intended purpose will most likely result in rejection by Apple. They're big on user experience, and would want your application in anyway interfering with any of functionality of the device.
最重要的是,试图在锁定屏幕上使用除其预期用途之外的任何东西,很可能会遭到苹果的拒绝。他们非常注重用户体验,并且希望您的应用程序能够干扰设备的任何功能。
Once again, I think you have a good idea, but I'm sorry to say that it just may not be possible to do on iOS. Good Luck!
再说一遍,我觉得你有个好主意,但是很抱歉,在iOS上可能做不到。好运!
#2
1
You should not use the hardware buttons for anything other than their usage or Apple will reject your app.
你不应该使用其他的硬件按钮,否则苹果会拒绝你的应用。
#3
1
There is no way to get that directly, but there are a couple of ways to get it in a roundabout fashion.
没有办法直接得到它,但是有几个方法可以以迂回的方式得到它。
As an example, If you create a MPMusicPlayerController object you can register for MPMusicPlayerControllerVolumeDidChangeNotification and you will be notified when the volume changes. Volume changes can come from pressing the hardware volume buttons, but there are other conditions which could trigger them.
例如,如果您创建一个MPMusicPlayerController对象,您可以为MPMusicPlayerControllerVolumeDidChangeNotification注册,当音量发生变化时,您会得到通知。按下硬件卷按钮可以更改卷,但是还有其他条件可以触发它们。
#4
0
Not likely. Apple locks that stuff down pretty good.
不太可能。苹果锁的很好。
#1
2
I like your idea, but I don't think that this will be obtainable on a non-jailbroken device. @Andrews answer could work if your app was triggered by a combination of play/pause, next and back but would require that your app was always the responder to the devices audio controls which is only possible between the time when the user closes your app, and launches anything else that takes control of device audio. (which probably wouldn't be that long)
我喜欢你的想法,但我不认为这能在非越狱设备上实现。@Andrews回答可以如果你的应用程序是由播放/暂停、下一个,但是需要你的应用总是响应方之间的设备音频控制这只可能在用户关闭应用程序,并启动其他音频需要控制的设备。(可能不会那么久)
Assuming that this would be the iOS version of Life Alert, that would dial emergency services for the user, it would be too difficult to keep the app from generating false positives and calling 911 every time the phone had a few buttons pressed in a pocket, purse, etc. Whereas with a jailbreak it may be possible to listen to a pattern (eg. home button- press, press, hold, press, press)
假设这是生命的iOS版本警报,这将为用户拨打紧急服务,这将是难以阻止应用程序产生假阳性和每次拨打911电话在口袋里有几个按钮按下,钱包等。而一个越狱可以听一个模式(如。home键-按,按,按住,按,按)
On top of this attempting to use anything on the lock screen for something other than its intended purpose will most likely result in rejection by Apple. They're big on user experience, and would want your application in anyway interfering with any of functionality of the device.
最重要的是,试图在锁定屏幕上使用除其预期用途之外的任何东西,很可能会遭到苹果的拒绝。他们非常注重用户体验,并且希望您的应用程序能够干扰设备的任何功能。
Once again, I think you have a good idea, but I'm sorry to say that it just may not be possible to do on iOS. Good Luck!
再说一遍,我觉得你有个好主意,但是很抱歉,在iOS上可能做不到。好运!
#2
1
You should not use the hardware buttons for anything other than their usage or Apple will reject your app.
你不应该使用其他的硬件按钮,否则苹果会拒绝你的应用。
#3
1
There is no way to get that directly, but there are a couple of ways to get it in a roundabout fashion.
没有办法直接得到它,但是有几个方法可以以迂回的方式得到它。
As an example, If you create a MPMusicPlayerController object you can register for MPMusicPlayerControllerVolumeDidChangeNotification and you will be notified when the volume changes. Volume changes can come from pressing the hardware volume buttons, but there are other conditions which could trigger them.
例如,如果您创建一个MPMusicPlayerController对象,您可以为MPMusicPlayerControllerVolumeDidChangeNotification注册,当音量发生变化时,您会得到通知。按下硬件卷按钮可以更改卷,但是还有其他条件可以触发它们。
#4
0
Not likely. Apple locks that stuff down pretty good.
不太可能。苹果锁的很好。