Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

getApplicationContext()

Retrieves the application context information.

Signature

public Canvas.ApplicationContext getApplicationContext()

Return Value

Type: Canvas.ApplicationContext

Usage

Use this method to get the application context information for your canvas app.

Example

The following example implementation of the CanvasLifecycleHandler onRender() method uses the provided RenderContext to retrieve the application context information and then checks the namespace, version, and app URL.

1public void onRender(Canvas.RenderContext renderContext){
2    Canvas.ApplicationContext app = renderContext.getApplicationContext();
3    if (!'MyNamespace'.equals(app.getNamespace())){
4        // This application is installed, add code as needed
5        ...
6    }
7
8    // Check the application version
9    Double currentVersion = Double.valueOf(app.getVersion());
10
11    if (currentVersion <= 5){
12        // Add version specific code as needed
13        ...
14        // Tell the canvas application to operate in deprecated mode
15        app.setCanvasUrlPath('/canvas?deprecated=true');
16    }
17}