Snapshots - Platform

🚧

Requirements

  • OpenFin CLI installed
  • OpenFin Runtime 15.80.49.30+
  • Windows Operating System | Mac not fully supported and may result in unexpected behavior

Getting and Applying Snapshots

In the Adding a Platform View to an Existing Window section, we loaded a brand-new Platform Window with two Views in it. Here we walk through how to retrieve (getSnapshot) a Platform layout and apply (applySnapshot) a previously saved Platform layout.

Getting a Snapshot

Paste the following code into the same console you were using in the Adding a Platform View to an Existing Window section and press enter to run the getSnapshot function. In the console, you should see a returned Snapshot Object. This is the object that Platforms uses to return the desktop back to this current state. You can store this object wherever you'd like, and use it later to apply this Snapshot.

// The `platform` here is the object we captured
const mySnapshot = await platform.getSnapshot();
console.log(mySnapshot);

Applying a Snapshot

Now that we have generated our Snapshot Object, let's use it to recreate our desktop using applySnapshot . First, let's shuffle our desktop around a bit.

  1. Close the window you created earlier (the one filled with www.example.com Views), move your windows to different locations.
  2. Move the Views in those windows to different locations.
  3. Execute the code below to get your desktop back to the way it was before.
// The `platform` here is the object we captured
platform.applySnapshot(mySnapshot, {closeExistingWindows: true});

Launching Platforms and Snapshots

Let's take a closer look at the Platform Configuration that we covered in Launching a Platform. To launch the Platform, use a manifest that has a top-level platform object instead of a startup_app object. This configuration object lets you define platform-level options such as

  • defaultWindowOptions
  • defaultViewOptions

Optionally, a Snapshot can be added as a top-level property to an application manifest. If a Platform is launched without a Snapshot, it launches as a headless controller. Once running, applications and Snapshots can be launched into the Platform using the following methods:

API calls

Once a Platform is launched and running, Snapshots can be launched into the Platform using applySnapshot. Content can also be launched into the Platform by manifest using startFromManifest. If that manifest also contains a snapshot object, that Snapshot is launched. Any View specified in the snapshot is assigned a randomly generated name to avoid collisions. If you are launching a legacy manifest without a Snapshot, the startup_app is launched as a single view in a new window.

Deep Linking (fins link)

The RVM permits deep linking to an OpenFin application from anywhere that can invoke a “link” like a browser, email client, or another OpenFin application. The RVM uses a custom protocol handler to invoke an application, if not already running, and passes context to a specific location within an OpenFin application via a uniform resource identifier (URI).

You can designate a snapshot manifest or legacy app manifest to be launched into the platform using deep linking by adding a appManifestUrl parameter that points at the manifest URL.

  • If an appManifestUrl parameter is included and the platform is not running, any snapshot that exists on the platform manifest is ignored and instead the content designated at the appManifestUrl is launched
  • If the content manifest designated in the parameter does not have a snapshot property but does have a startup_app property, then the platform attempts to launch a single window with a single view that takes the applicable startup_app options in the manifest (similar to the launchLegacyManifest API).

Example Deep Link launching content:
fins://mydomain.com/path-to-platform-manifest/app.json?$$appManifestUrl=


Did this page help you?