> ## Documentation Index
> Fetch the complete documentation index at: https://docs.directgvr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Host custom protocol

> Register and handle a custom URL protocol in the DirectGVR client.

This document describes how to implement custom protocol handler. When the DirectGVR client first starts it is possible to get the url using `app.getCommandFieldByName("schema-url")`. If the client is already running when the user initiates the schema request, it will be sent through to the client through the `SkinApp.NewCommandLine` notification.

## Windows

Custom protocol handlers are registered in Windows by creating specific registry keys in `HKEY_CLASSES_ROOT`.

The following workflow tasks create a custom protocol handler called `myhandler://` for an application called `My Application`. These are written in YAML but they can also be written in JSON depending on what your workflow uses.

```json theme={null}
## Create HKEY_CLASSES_ROOT/myhandler url protocol

createUrlProtoHandlerRoot:
  type: registryKeyWrite
  hive: root
  location: myhandler
  key: URL Protocol
  value: "My Application"

## Create HKEY_CLASSES_ROOT/myhandler shell open command 

createUrlProtoHandlerCommand:
  type: registryKeyWrite
  hive: root
  location: myhandler\shell\open\command
  key: ''
  value: '"{modulePath}" --open="%1"'
```

When the DirectGVR client first starts it is possible to get the url using `app.getCommandFieldByName("open")`. If the client is already running when the user initiates the schema request, it will be sent through to the client through the `SkinApp.NewCommandLine` notification.

### macOS

Custom protocol handlers are registered in macOS in the application bundle's Info.plist. The operating system can choose at any time to recognize the custom protocol handler of an application bundle on disk. It can be recognized by the operating system when copying the application bundle into the Applications folder or be recognized when opening a DMG. However, the operating system will ignore the application bundle if it is located in certain directories such as the temp directory.

When building your skin using the Builder console in DIRECT 6.1 or higher include an Info.plist in the root directory of the skin; it will get merged with the Info.plist of the DirectGVR client. The following Info.plist creates a custom protocol handler called `myhandler://` for an application called `My Application`.

```xml theme={null}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>CFBundleURLName</key>
            <string>My Application URL</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>myhandler</string>
            </array>
        </dict>
    </array>
</dict>
</plist>

```

All schema requests will be sent to the `SkinApp.NewCommandLine` notification. On macOS, the argument name is `--open`.

#### More resources

* [Custom Protocol Handling — How To | by Tal Martsiano | The Startup | Medium](https://medium.com/swlh/custom-protocol-handling-how-to-8ac41ff651eb)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.