Previewing the publisher's video before streaming

Note that, by default, the view of the Publisher contains the video of the publisher when the publisher starts streaming to the session.

To see a preview of the video before the Publisher starts streaming, call the startPreview() method of the Publisher object:

If you call the startPreview() method, you must call the destroy() method of the Publisher to remove the Publisher's view (and the video), when the publisher stops streaming (when the onStreamDestroyed(PublisherKit publisher, Stream stream) method of the PublisherListener is called).

Checking for camera access

We recommend that you check for camera access app permissions prior to publishing and, if access is denied, give feedback to the end-user about setting app access permissions. (An end-user can enable access to the camera via the iOS Settings: Privacy > Camera.)

The end-user is prompted to grant access to the camera for any app requesting it.

You may control when this prompt is shown by calling AVCaptureDevice requestAccess(for:completionHandler:) with AVMediaType.Video, which will give the prompt on first run. Subsequent calls will execute the completion handler with the user's stored preference.

Check whether a client has publish capabilities

Once you have connected to a session, you can check if the client can publish.

Check the value of the capabilities.publish property of the Session object. If it is set to 1, the client can publish:

To publish, the client must connect to the session with a token that is assigned a role that supports publishing. There must be a connected camera and microphone. Also, the client environment must support publishing (see Browser support).

Also, publishing is only supported on HTTPS pages.