[英]prompt the user using a UIAlertController if iOS and device lower than iOS11 and iphone 8?
If a user installs up an application in a device lower than iPhone 8 and iOS version lower than iOS 11, a UI Alert pop" the minimum requirements to use the app is iOS 11 and iPhone 8 or above", and there is an ok button. 如果用户在低于iPhone 8和低于iOS 11的iOS版本的设备中安装应用程序,则会弹出UI警报“使用该应用程序的最低要求是iOS 11和iPhone 8或更高版本”,并且有一个确定按钮。 I want to tell the user that is their device is not supported. 我想告诉用户,不支持他们的设备。 Here is what I have in the code. 这是代码中的内容。
Note: I did set the deployment target to iOS11 but how can I set it for device iPhone8 注意:我确实将部署目标设置为iOS11,但是如何为设备iPhone8设置它?
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let alertController = UIAlertController(title: "Foo", message: "Bar", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
// check
if #available(iOS 11.0,*)
{
}
else
{
present(alertController, animated: true, completion: nil)
}
}
}
You can require that the device support nfc
in your info.plist
. 您可以在info.plist
要求设备支持nfc
。
Per Apple: https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/DeviceCompatibilityMatrix/DeviceCompatibilityMatrix.html 每个Apple: https : //developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/DeviceCompatibilityMatrix/DeviceCompatibilityMatrix.html
If you really, Really, REALLY (be sure) want to restrict usage of your app to iPhone 8 during runtime, you can read out the device model with this little extension to UIDevice
from this SO Answer . 如果您确实(确实)确实希望在运行时限制对iPhone 8的应用程序使用,则可以从SO Answer中读取对UIDevice
进行此扩展的设备模型。
Beware, that Apple may not - or most likely will not - let you publish your app to the AppStore. 注意,Apple可能不会-或很可能不会-让您将应用发布到AppStore。 Highly avoid killing the app by code!! 极力避免通过代码杀死应用!! Just show the alert, that your app is not designed to run on any device other than iPhone 8. 仅显示警报,您的应用程序不旨在在iPhone 8以外的任何设备上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.