ios iPhone 应用程序可以在启动时启动吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9300815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:52:56  来源:igfitidea点击:

Can iPhone apps start on start-up?

iphoneios

提问by Alex Coplan

I've answered twodifferent questionsnow, both explaining how VOIP apps don'tstart on start-up, yet people seem to think they do.

我现在已经回答了两个不同的问题,都解释了 VOIP 应用程序如何不在启动时启动,但人们似乎认为它们会启动。

I'm not 100% sure myself, someone linked me to a part of the apple docs, which doesn't really mention anything about auto-starting of apps.

我自己也不是 100% 确定,有人将我链接到Apple 文档一部分,该文档并未真正提及有关应用程序自动启动的任何内容。

I was originally going on prior knowledge and this answer, but after another person saying that they do, I'm really not sure.

我最初是在研究先验知识和这个答案,但在另一个人说他们这样做之后,我真的不确定。

As far as I'm aware, apps only react to push notifications, and can't be launched into the background when a device is turned on.

据我所知,应用程序仅对推送通知做出反应,并且无法在设备打开时启动到后台。

Can we please clarify whether it is possible to auto-start an app or not?

我们能否澄清一下是否可以自动启动应用程序?

回答by Tim

Take a look at the UIBackgroundModes section in this document- it seems to state that adding the voipkey willautostart an app on boot.

查看本文档中的 UIBackgroundModes 部分- 似乎说明添加voip密钥在启动时自动启动应用程序。

Edit:a sample appseems to confirm this behavior.

编辑:一个示例应用程序似乎证实了这一行为。

回答by user3344362

I confirm that setting VOIP mode works. However, I've found that the app won't restart after power up unless it was running when the device was powered off. Furthermore, the app won't actually restart on the recently powered up device until the device is unlocked after power up.

我确认设置 VOIP 模式有效。但是,我发现应用程序不会在开机后重新启动,除非它在设备关机时正在运行。此外,应用程序实际上不会在最近通电的设备上重新启动,直到设备在通电后解锁。

回答by sercancici

OK, I don't know if this classifies as an answer but I feel obligated to say. I am developing an app that both tracks significant location changes and provides VoIP features. The app has voipkey in Required background modes. I tried some cases which I would like to share the results:

好的,我不知道这是否属于答案,但我觉得有必要说一下。我正在开发一个应用程序,它既可以跟踪重要的位置变化,又可以提供 VoIP 功能。该应用程序voip必需的后台模式中有键。我尝试了一些我想分享结果的案例:

  • App is in Debug mode - Turned off while app was running (active or background) - iOS 7.1.1 (11D201) and iPhone 4 (product name: iPhone3,2):
  • 应用程序处于调试模式 - 应用程序运行时关闭(活动或后台) - iOS 7.1.1 (11D201) 和 iPhone 4(产品名称:iPhone3,2):

When booted, app is running in background, as well as other apps that were running before. I do not think this is related to VoIPin any way.

启动时,应用程序在后台运行,以及之前运行的其他应用程序。我认为这与VoIP没有任何关系。

  • App is in Debug mode - Turned off while app was terminated - iOS 7.1.1 (11D201) and iPhone 4 (product name: iPhone3,2):
  • 应用程序处于调试模式 - 应用程序终止时关闭 - iOS 7.1.1 (11D201) 和 iPhone 4(产品名称:iPhone3,2):

When booted, the app is not running, there are no logs in configuration utility, server says the user is not registered I cannot call it from other devices; and yet the other apps that are not related to voip or location tracking but were open before turning off are at least loaded in memory. Meaning, the voipkey did not work.

启动时,应用程序未运行,配置实用程序中没有日志,服务器说用户未注册我无法从其他设备调用它;而其他与 voip 或位置跟踪无关但在关闭之前已打开的应用程序至少已加载到内存中。意思是,voip钥匙没用。

I have continued the test with the same app but this time downloaded it from app store. The results are the same. Changed the device and os to iPhone 3G (product name: iPhone2,1) and iOS 6.1.6 (10B500). Nothing changed both in debug and release modes.

我用同一个应用程序继续测试,但这次是从应用程序商店下载的。结果是一样的。将设备和操作系统更改为 iPhone 3G(产品名称:iPhone2,1)和 iOS 6.1.6 (10B500)。在调试和发布模式中没有任何变化。

I have told my boss that Apple provides this behavior and it can be done. Then I had second thoughts and tried, now I am desperately trying to find another way. Going to send my regards to Apple about this.

我已经告诉我的老板,Apple 提供了这种行为并且可以做到。然后我重新考虑并尝试了,现在我正在拼命寻找另一种方法。我要就此向 Apple 致以问候。

回答by sch

You can not launch an application without user interaction. The user has to click on the app icon, on push notifications, on a custom link. May be there are other ways I am not aware of, but even if they exist, they require user interaction to intentionally launch the app.

您无法在没有用户交互的情况下启动应用程序。用户必须单击应用程序图标、推送通知和自定义链接。可能还有其他我不知道的方法,但即使它们存在,它们也需要用户交互才能有意启动应用程序。

Edit

编辑

It turns out, as Tim mentioned, there might be an exception for VOIP apps.

事实证明,正如蒂姆所说,VOIP 应用程序可能有例外。

回答by Qiulang

I have been developing VoIP apps and I can confirm that VoIP app will autostart when iPhone reboots as long as user doesn't kill it before reboot. When iOS autostart voip app only application:didFinishLaunchingWithOptions:will be run, i.e. applicationDidBecomeActive:won't be run.

我一直在开发 VoIP 应用程序,我可以确认 VoIP 应用程序会在 iPhone 重新启动时自动启动,只要用户在重新启动之前没有将其杀死。当 iOS 自动启动 voip 应用程序只会application:didFinishLaunchingWithOptions:运行,即applicationDidBecomeActive:不会运行。

I used to doubt whether iOS will automatically restart the voip app when it crashes. After investigating I find iOS does automatically restart the voip app but if it keeps crashing iOS will then try servals time before it finally gives up.

我曾经怀疑iOS是否会在崩溃时自动重启voip应用程序。经过调查,我发现 iOS 确实会自动重新启动 voip 应用程序,但如果它不断崩溃,iOS 将在最终放弃之前尝试 servals 时间。

If you check iPhone console output from xcode, you can see logs like these after the first crash

如果您从 xcode 检查 iPhone 控制台输出,您可以在第一次崩溃后看到这样的日志

.. 
Service exited due to signal: Abort trap: xxx
Unable to get short BSD proc info for xxxx: No such process 
Application 'UIKitApplication:xxxxx]' crashed. 
...

回答by lupinglade

Significant location change or region monitoring also causes an app to launch on boot as long as its turned on and left on. No UIBackgroundModes key is necessary for this.

显着的位置变化或区域监控也会导致应用程序在启动时启动并保持打开状态。为此不需要 UIBackgroundModes 键。