Digimarc Resolver

By default, the drop-in component uses the Digimarc Resolver web service to retrieve content information for payloads. The resolver takes a Payload, which the SDK has detected, and turns it into a resolve result, which contains one or more content items.

Resolving Payloads

In many use cases, a payload has no inherent meaning. It's meaningful only in its association with a content item that contains actionable, application-specific metadata. The process of creating a payload and associating it with a content item is managed through the Digimarc Print & Audio Module.

In most cases, the action within a content item is to redirect the user to an interactive web experience. The metadata consists of the following items provided by the content owner to support that action:

  • A URL
  • A title
  • A subtitle
  • A thumbnail icon
  • An identifying action token
Note

When a user launches the content (URL) within a content item, the application is required to invoke the reportAction method of the Resolver with the action token associated with the content item.

The Resolver might return errors in some circumstances, including:

  • The network isn't reachable or network data transfers are corrupted.
  • Digimarc Resolver Service credentials haven't been supplied or aren't valid.
  • The Digimarc Resolver Service isn't available.

The Digimarc Resolver Service production servers are redundant and have high availability, so this situation is unlikely, but alternative resolver services for testing (for example, the Digimarc Labs service) might not always be available.

Handling Product Packaging Codes

The default behavior of the drop-in component is to send all decoded payloads to the Digimarc Resolver. Packaging payloads of all kinds might be sent to the Digimarc Resolver, but if a mobile experience hasn't been defined for a payload by the content owner, a default result containing a Google Product Search is returned. In some cases, this might not be desirable. For instance, a retail application might want to use the data from a package scan to look up information in a private product database. The drop-in component provides a mechanism by which an application can decide whether each decoded payload is to be resolved. Examples of usage for each platform are below.

iOS

The DetectorViewController defines a delegate protocol that can be implemented to respond to detections. Implementation of any method in the protocol is optional. For more information see the DetectorViewControllerDelegate protocol.

func detectorViewController(_ viewController: DetectorViewController, shouldResolvePayloadsFor result:
ReaderResult) -> [Payload]? {
  //this example only handles the first (highest priority) Payload and ignores the others
  guard let Payload = result.Payloads.first else {
  //if there is no Payload as part of the result then return
  return
  }
  if let GTIN14Value = Payload.representations[.GTIN14] {
    //handle as a GTIN14 with the value contained in GTIN14Value
  } else {
    //return just the first Payload to be resolved
  return [Payload]
  }
}
func detectorViewController(_ viewController: DetectorViewController, resolvedContent: ResolvedContent,
for Payload: Payload)
{
  //handle resolved content here
}
func detectorViewController(_ viewController: DetectorViewController, didReceiveError error: Error)
{
  //errors are returned here
}
Note

This sample code is provided as general guidance. Swift versions might result in required code updates might not be reflected in this document. If you copy/paste code snippets, be aware that line breaks and other formatting could change.

Android

The DMSDetectorView control requires using either a DISListener or a DISExtendedListener object. Both provide a method which is called immediately after a payload is decoded. In both cases, the method returns a boolean value at the end of the callback. If the application returns true, the Payload is sent to the resolver. If the value is false, the payload isn't resolved. In the DISListener interface, the method called is onDigimarcDetected(), and in the DISExtendedListener interface, the method is onImageDetected().

DISListener listener = new DISListener()
{
  @Override
  public void OnMediaIdentified( MediaType type, String Payload, String title, String subtitle, String content )
  {
  }
  @Override
  public boolean OnDigimarcDetected( Payload Payload )
  {
    String value;
    boolean shouldResolve = true;
    if ( ( value = Payload.getRepresentation( Payload.BasicRepresentation.GTIN_14 )) != null )
    {
      // “value” contains a GTIN 14 product packaging code. This could be from a Digimarc
      // Barcode, a UPC A barcode or an EAN 8 or EAN 13 barcode. We’ll return false so the
      // Payload isn’t resolved. App-specific logic would go here to handle the package code.
      shouldResolve = false;
    }
    return shouldResolve;
  }
  @Override
  public void onError( int statusCode )
  {
  }
  @Override
  public void onWarning( int statusCode )
  {
  }
};