Create an iOS shortcut app and quickly open the key with NFC

I want to unlock the smart lock smarter.

When I came back to the front of the entrance

Take out the mobile phone → (remove the mask) → cancel face recognition → search for the app → open the app → unlock

It is necessary to go through the process, but we will create an app that reduces the two steps of "find an app → open an app" using NFC tags.

Especially in this mask environment, I want to reduce even one process.

The smart lock has a setting that automatically unlocks when approaching with GPS, but since the GPS is constantly checked, the battery is exhausted and it is often faster to open it manually than the check interval. In the first place, the apartment in the inner corridor cannot be used because the radio waves do not reach it.

The official app does not support iOS shortcuts, so create your own app to support it. I will redirect to the official app from there.

NFC tag

10 NFC stickers NTAG 213 NFC tag/25 mm (1 inch) black circle

I chose a sticker type that does not stand out in black. I stick this on the front door, but I think most front doors are made of metal, but be careful as sticking it on metal will slow down the reaction! I stuck it on the wall near the intercom.

For the time being, the entrance and corridor of the condominium are usually treated as common areas, so please be careful.

iOS app creation

I don't need the View part in particular, but I made it with Swift UI.

Open another app

First, we will create an app that redirects to the official app. In my case, I use bitlock, so I named it lunchBitlock. I try to open the official app the moment the screen is displayed.

import SwiftUI

@main
struct lunchBitlockApp: App {
    @Environment(\.scenePhase) private var scenePhase

    var body: some Scene {
        WindowGroup {
            ContentView()
                .onAppear {
                    lunchApp()
                }
                .onChange(of: scenePhase) { _ in
                    lunchApp()
                }
        }
    }
    
    func lunchApp() -> Void {
        if let url = URL(string: "app.jp.co.bitkey.bitlock:") {
            UIApplication.shared.open(url)
        }
    }
}

It is difficult to find out because the URL scheme for each application is not published, Android apps often use the same name, so you can guess from the package name written in the URL of the Google Play store.

Make shortcuts compatible

From the iOS shortcut Xcode menu

File → New → File → SiriKit Intent Definition File

Create a file to support shortcuts with.

Add Custom Intents to the Intent Definition file you created. No special settings are required, but let's set the title so that it is easy to understand.

All you have to do is add this file to support iOS shortcuts. The app will be displayed in the action part of the shortcut app.

Automation settings

Add a new one from the automation settings of the shortcut app.

If you register the NFC tag you want to react to "when" and register the application you made in "do (action)", you can create automation like this.

If you hold your iPhone over the NFC tag in this state, the app will open automatically, which is convenient.

end

When you get tired and tired and come home, the process of "finding an app" is troublesome, and when you open another app, you can switch apps quickly, which is relatively convenient.

In my case, I also registered automation to open this app when connecting to my home WiFi. Sometimes this one reacts faster, but it accidentally explodes when switching to WiFi.

*** Please correspond to the official. .. .. *** ***

Recommended Posts

Create an iOS shortcut app and quickly open the key with NFC
Create an app with Spring Boot 2
Create an app with Spring Boot
Create an infinite scroll with Infinite Scroll and kaminari
Create an app by specifying the Rails version
Let's quickly create an app that uses Firestore! !!
Create an EC site with Rails5 ④ ~ Header and footer ~
The basics of the process of making a call with an Android app
Create an app catalog site using CLI for Microsoft 365 with Docker
Create a JVM for app distribution with JDK9 modules and jlink
[Swift 5] Processing and precautions for transitioning to the iOS settings app