Upgrade to Pro — share decks privately, control downloads, hide ads and more …

感染症・熱中症対策に温度・湿度を測定できる iOS アプリを開発・配信

感染症・熱中症対策に温度・湿度を測定できる iOS アプリを開発・配信

Daichi Tanaka

April 04, 2023
Tweet

Other Decks in Technology

Transcript

  1. 感染症・熱中症対策に 温度・湿度を測定できる iOS アプリを開発・配信 2023/04/04 田中 大地 キーワード 個人開発 IoT

    デバイスを利用した測定 BLE 通信 IoT デバイスと接続できる iOS アプリの審査 SwiftUI
  2. 全体像 MESH アプリをインストールした iPhone / iPad / Mac (M1 など)

    BLE 通信 温度・湿度を測定 測定したデータを iPhone 等に送信 受信した測定データを表示・端末に保存
  3. 開発期間と環境 PC MacBook Air(2020,M1) メモリ:16GB ストレージ:1TB DB Realm IoT デバイス

    MESH 温度・湿度ブロック 測定できる温度の範囲: -10℃ 〜 50℃ 測定できる湿度の範囲: 0% 〜 100% 充電: Micro-USB IDE Xcode 言語 Swift バージョン管理 GitHub フレームワーク SwiftUI その他 Photoshop iPhone SE (2nd Gen) 開発期間 2022年12月初旬 ~ 2023年1月中旬 開発環境
  4. Realm import Foundation import RealmSwift final class Record: Object, ObjectKeyIdentifiable

    { @Persisted(primaryKey: true) var id: UUID = UUID() @Persisted var date: Date @Persisted var deviceName: String @Persisted var temperatureCelsius: Double @Persisted var humidityPercent: Double @Persisted var batteryLevel: Double override init(){} init(date: Date, deviceName:String, temperatureCelsius:Double, humidityPercent:Double, batteryLevel:Double){ self.date = date self.deviceName = deviceName self.temperatureCelsius = temperatureCelsius self.humidityPercent = humidityPercent self.batteryLevel = batteryLevel } } モバイル端末向けのデータベース
  5. SwiftUI • Swift を利用して少ないコード量で UI を実装できるフレーム ワーク 感想 • UIKit

    での実装に慣れていると、最初は戸惑う • SwiftUI での実装に慣れると便利
  6. SwiftUI import SwiftUI import CoreBluetooth @main struct Thermometer_HygrometerApp: App {

    @StateObject var manager: DeviceManager = DeviceManager() var body: some Scene { WindowGroup { ContentView() .environmentObject(manager) } } }
  7. SwiftUI import Foundation import CoreBluetooth import SwiftUI class DeviceManager: NSObject,

    ObservableObject { private let centralManager: CBCentralManager private let services:[CBUUID] = [CBUUID(string: MESH.UUID.description)] @Published var devices:[Device] = [] @Published var recievedData:[Int] = [] @Published var batteryLevelData:[Int] = [] override init(){ centralManager = CBCentralManager(delegate: nil, queue: nil) super.init() centralManager.delegate = self self.scan() } // (中略) }
  8. SwiftUI import SwiftUI import Foundation struct MainView: View { @EnvironmentObject

    var manager: DeviceManager @State var isSave: Bool = false var body: some View { VStack { VStack { Text(String.format(Date())) .font(.title3) .fontWeight(.bold) VStack { if manager.recievedData.count != 0 { MeasurementDataView(data: Double.convert(manager.recievedData[4],manager.recievedData[5]), type: .thermometer) MeasurementDataView(data: Double(manager.recievedData[6]), type: .hygrometer) } else { MeasurementDataView(data: nil, type: .thermometer) MeasurementDataView(data: nil, type: .hygrometer) } } .padding() } } // (中略) } }
  9. 実際に測定した結果 • 8畳 1ルーム 1人暮らし エアコンはつけっぱなし (暖房 23℃ 風速:最大) •

    室内の湿度:1日で10〜20%前後変動 • 朝は湿度40%以下になる • 部屋の中で洗濯物を干す・湯を沸かす → 50%後半~60%台に • 加湿器をわざわざ購入しなくても良いかも ... (部屋や人数による)
  10. 1回目の審査結果 「却下」 Guideline 2.1 - Information Needed Before we can

    complete our review of your app, we need a video that demonstrates the current version, 1.0.0, in use on a physical iOS device, pairing and interacting with the designated hardware. The demo video should: - Show your app running on a physical iOS device, not on a simulator. - Clearly documents all relevant app features, services, and user permission requests. Next Steps Provide a link to the video in the App Review Information section of your app’s page in App Store Connect and reply to this message. You can use a screen recorder to capture footage of your app in use. Note that if your app can only be reviewed with a demo video, you’ll need to provide an updated demo video for every app submission.