ios - 仅适用于 iPhone 的应用程序

标签 ios xcode

我的应用被拒绝了,因为它在 iPad 上崩溃了。
老实说,它应该崩溃,因为它没有我的应用程序使用的 sim 卡(用于发送消息)。我在我的构建中制作了设备:iphone 和部署目标 iphone。然而出于某种原因,苹果公司的人仍然试图在 iPad 上运行它。我怎样才能让我的应用程序只适用于 iPhone?没有理由捕获异常并尝试在 iPad 或 iPod touch 上运行它,因为大多数应用程序功能都包含发送短信。
我该怎么办 ?以及如何确保应用程序只能在 iPhone 上运行,而不是在 iPad 或 iPod touch 上

最佳答案

我认为一种选择是提供 UIRequiredDeviceCapabilities应用程序 info.plist 中的标志。
你可以给Telephonysms ,所以它应该过滤掉没有 sim 卡的设备。

来自 iphone app programming guide .

UIRequiredDeviceCapabilities — The App Store uses this key to determine the capabilities of your app and to prevent it from being installed on devices that do not support features your app requires



如果您阅读应该会更好应用相关资源上述 pdf 中的部分(第 93 页)。

从上述文件中,

If your app requires the presence or absence of specific device capabilities in order to run, you must declare those requirements using the UIRequiredDeviceCapabilities key in your app’s Info.plist file. At runtime, iOS cannot launch your app unless the declared capabilities are present on the device. Further, the App Store requires this information so that it can generate a list of requirements for user devices and prevent users from downloading apps that they cannot run



它说,iOS 在启动之前会检查所需的设备功能。所以我认为你没有任何问题。关于模拟器,我不确定上述是否适用于他们,因为我们甚至可以在模拟器中模拟来电(你知道模拟器没有 SIM 卡)。所以我不确定在这种情况下有多少模拟器可以帮助你。

还有一件事,Apple 只会在应用程序在非 sim 设备上运行时崩溃时拒绝该应用程序。 Apple 总是批准一个应用程序在使用它之前优雅地检查设备功能是否存在。在使用短信功能之前,您可以检查设备是否可以发送短信。
if([MFMessageComposeViewController canSendText]){
  // send sms
}

如果它不能发送短信,显示同样的提示框。只需 2 行代码,但不那么头痛和紧张..

关于ios - 仅适用于 iPhone 的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13678181/

相关文章:

ios - 从 UITableViewCell 内的 UITextField 中删除 Tap 手势

objective-c - 无法退出 Xcode

javascript - 使用 PhoneGap/Cordova 写入文件期间 iOS UI 卡住

ios - 如何检查 UITableViewCell 标签是否被截断?

ios - 如何将 SwiftUI View 包装在 ASDisplayNode 中

iOs 两次部署相同的应用程序

ios - "Allocation Type"菜单在 Instruments 中被禁用

ios - 如何使 UITextView 适合 xcode 中的形状

objective-c - 你能在一个选择器中存储多个方法吗?

ios - UIKeyInput 在 iPad 上不可用?