<!--
{
  "availability" : [
    "iOS: 26.4.0 -",
    "iPadOS: 26.4.0 -",
    "macCatalyst: 26.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WiFiAware",
  "identifier" : "/documentation/WiFiAware/WASharedSecret/ProtocolName/init(_:)-7marr",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Wi-Fi Aware"
    ],
    "preciseIdentifier" : "s:9WiFiAware14WASharedSecretV12ProtocolNameVyAESgSScfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a custom protocol name using the provided unique string.

```
init?(_ string: String)
```

## Parameters

`string`

The string to use as the underlying protocol name, which must be equal to or greater than three characters long. The framework converts the string to UTF-8 prior to hashing in the derivation.

## Return Value

A new [`WASharedSecret.ProtocolName`](/documentation/WiFiAware/WASharedSecret/ProtocolName), or `nil` if the provided string is too short.

## Discussion

Custom protocols need to specify a string that identifies the protocol that uses the shared secret. The string must be representable as UTF-8, and normalize to the same value when represented as bytes. A best practice is to use ASCII-compatible values to avoid normalization issues. Set the same value on the local and remote devices in order to generate the same shared secret.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)