Redacting views via your source code ensures your redaction configuration are tied directly to the application structure.
Redact per-view
To redact a single view you can call cobrowseRedacted on any UIView or SwiftUI View.
let uiView =UIView()uiView.cobrowseRedacted()
let swiftUIView =ExampleView()swiftUIView.cobrowseRedacted()
Any children of the view will also be redacted allowing you to redact container views like VStack or a UIView that contains subviews.
Redact views within UIViewController via CobrowseIORedacted
You may wish to return all the views that should be redacted at once per view controller. By conforming your UIViewController to CobrowseIORedacted you can proved the reference to each UIView that should be redacted.
Redact views within custom delegate via CobrowseIODelegate
If you can't make changes to the UIViewController or you wish to centralize your redaction logic. You will need an object that conforms to CobrowseIODelegate and implement the cobrowseRedactedViews(for vc: UIViewController) within it.
This method provides you with the UIViewController whereby you return the views within that view controller you wish to redact.
Be sure to set the delegate property to your custom delegate before calling start().
Redact WebView content
Your app may show web content that contains elements that you wish to redact. This can be achieved by setting the webviewRedactedViews property to an array of CSS selectors that identify the elements to be redacted.
2. Selector based redaction
You can use CSS-like selectors to identify which views should be redacted. These selectors can be defined within your application using our SDK or via the Cobrowse dashboard.
Via SDK
Adding selectors via code ensures that list is tied to that version of the application.
You can use the class name of any UIView, the view's integer tag value or any property on the UIView that is string representable with no additional configuration.
You will need to use the cobrowseSelector(tag:, id:, classes:, attributes:) view modifier filling our the values manually.
This view can now be referenced using the selector of:
Adding selectors via the dashboard can be useful if your app is already in production and you need to redact a field retrospectively, either due to a missed redaction entry in the app build or changing requirements.
Private by Default
Sometimes you may want to redact everything on the screen, then selectively "unredact" only the parts your support agents should be able to see. This is particularly useful on applications that require a higher privacy standard or where only specific sections of the App should be visible to the agent.
To achieve this, you should return all of your application's root views via the cobrowseRedactedViews(for vc: UIViewController) delegate method.
Please note the example below may not redact all your root views as this can be application dependent.
Once you've done this, your application root views will be redacted by default and you'll be able to unredact child components to make them visible to the agents by implementing cobrowseUnredactedViews(for vc: UIViewController) in your CobrowseIODelegate class:
Alternatively, you can implement CobrowseIOUnredacted protocol in your UIViewController subclasses:
Redaction Playground
To explore and modify redaction in your apps you can use the Redaction Playground.
class ExampleDelegate: NSObject, CobrowseIODelegate {
func cobrowseRedactedViews(for vc: UIViewController) -> [UIView] {
// Return an array of UIViews to redact
// For example only the subviews that have the tag of 1
vc.view.subviews.filter { $0.tag == 1 }
}
}
let delegate = ExampleDelegate()
let cobrowse = CobrowseIO.instance()
cobrowse.delegate = delegate
cobrowse.start()
let cobrowse = CobrowseIO.instance()
cobrowse.webviewRedactedViews = [ ".redacted", ...some other selectors... ]
class ExampleDelegate: NSObject, CobrowseIODelegate {
func cobrowseUnredactedViews(for vc: UIViewController) -> [UIView] {
// Return an array of UIViews to unredact
// For example only the subviews that have the tag of 1
vc.view.subviews.filter { $0.tag == 1 }
}
}
class ExampleViewController: UIViewController, CobrowseIOUnredacted {
let imageView: UIImageView
@IBOutlet weak var label: UILabel!
...
func unredactedViews() -> [UIView] {
[imageView, label]
}
}