How to detect an Iphone X programmatically?

Swift and Objective-C developer tutorial on how to detect if an app is running on iPhone X
12 October 2017   27696

If you have an iOS app, now, with release of iPhone X you can face some new issues. In this tutorial, we will show you how to programmatically detect if an application is running on iPhone X.

Unfortunatelly, there is no direct methods on how to solve this issue. But let's use backdoor. Iphone X screen is 1125px X 2436px. So, we can use this information to solve this task.

Swift 3 and upper

if UIDevice().userInterfaceIdiom == .phone {
        switch UIScreen.main.nativeBounds.height {
        case 1136:
            print("iPhone 5 or 5S or 5C")
        case 1334:
            print("iPhone 6/6S/7/8")
        case 2208:
            print("iPhone 6+/6S+/7+/8+")
        case 2436:
            print("iPhone X")
        default:
            print("unknown")
        }
    }

Objective C

    if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone) {

        switch ((int)[[UIScreen mainScreen] nativeBounds].size.height) {

            case 1136:
                printf("iPhone 5 or 5S or 5C");
                break;
            case 1334:
                printf("iPhone 6/6S/7/8");
                break;
            case 2208:
                printf("iPhone 6+/6S+/7+/8+");
                break;
            case 2436:
                printf("iPhone X");
                break;
            default:
                printf("unknown");
        }
    }

or use screenSize.height as float 812.0f not int 812   

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    if (screenSize.height == 812.0f)
        NSLog(@"iPhone X");
}

Notice

DO NOT use the userInterfaceIdiom property to identify the device type, as the apple documentation explains,

For universal applications, you can use this property to tailor the behavior of your application for a specific type of device. For example, iPhone and iPad devices have different screen sizes, so you might want to create different views and controls based on the type of the current device.
 

Apple documentation

This property is just used to identify the running app's view style. However, the iPhone app (not the universal) could be installed in iPad device via App store, in that case, the userInterfaceIdiom will return the UIUserInterfaceIdiomPhone, too.

The right way is to get the machine name via uname.

Apple to Develop CryptoKit Framework

Using CryptoKit, developers will be able to perform cryptographic operations, including hashing and key generation
05 June 2019   483

Apple is going to present a set of tools for developers CryptoKit, integrated into the new iOS 13. It is reported by The Block.

It is reported that with the help of CryptoKit, developers will be able to perform cryptographic operations, including hashing and key generation. This will increase the security of applications and automate the execution of tasks.

It is also known that the toolkit will allow you to interact with both private keys managed by the Secure Enclave system and public ones, as well as generate encryption / decryption keys for message authentication.

For the first time, developers can leverage the secure enclave to manage a user’s keys in an iPhone, achieving a similar level of security to hardware wallets.
 

Alejandro Machado

Co-founder, Open Money Initiative

Apple is interested in blockchain technology. So, in February, the company reported to the US Securities and Exchange Commission (SEC) on the observance of human rights in a global network of suppliers of raw materials for production. Notably, the document said that Apple was involved in the development of the Blockchain Handbook for the Responsible Business Alliance (RBA) Initiative for Mineral Supply Chains.