func setupRemoteModel()

in mlkit/swift-snippets/ModelManagement.swift [20:44]


    func setupRemoteModel() {
        // [START setup_remote_model]
        let initialConditions = ModelDownloadConditions(allowsCellularAccess: true,
                                                        allowsBackgroundDownloading: true)
        let updateConditions = ModelDownloadConditions(allowsCellularAccess: false,
                                                       allowsBackgroundDownloading: true)
        let remoteModel = RemoteModel(
            name: "your_remote_model",  // The name you assigned in the console.
            allowsModelUpdates: true,
            initialConditions: initialConditions,
            updateConditions: updateConditions
        )
        ModelManager.modelManager().register(remoteModel)
        // [END setup_remote_model]
        
        // [START start_download]
        let downloadProgress = ModelManager.modelManager().download(remoteModel)
        
        // ...
        
        if downloadProgress.isFinished {
            // The model is available on the device
        }
        // [END start_download]
    }