hasLaunchContext function

If your task is an event handler, when your task is loading, call the hasLaunchContext function to determine if your task is being launched as a result of an application linking event. Doing so allows your task to determine if it needs to collect event information and display a specific context, or if it can display the main page.

Invoking the function

Call the hasLaunchContext function only if the launching option specified for your task in the handler definition is launch with context or launch with context and reload. For the launch without context launching option, z/OSMF core does not collect event information because there is no context to display; therefore, it is not necessary for your task to call the hasLaunchContext function.

For the launch with context and switch launching option, z/OSMF core alerts your task that an event has occurred when it calls the callback function you specified for the subscribe function; therefore, it is not necessary for your task to call the hasLaunchContext function to determine if an event has occurred.

To call the hasLaunchContext function, use the syntax shown in Figure 1.

Figure 1. Syntax to use to call the hasLaunchContext function
win.global.applinker.hasLaunchContext();

Return values

The hasLaunchContext function returns a Boolean value, which indicates the following:
true
Indicates that the Application Linking Manager delivered an event to the task. Call the getEventFromUrl function to parse the URL that z/OSMF core used to launch the task and retrieve the event information.
false
Indicates that the Application Linking Manager has not delivered an event to the task. In this case, z/OSMF core will launch the task without context.

Example

Figure 2. Sample code for the hasLaunchContext function
function init(){
{
  if(win.global.applinker.hasLaunchContext()){
  //The task was opened with application linking; therefore, update context.

  //Use the getEventFromURL function to obtain the context.
  var result = win.global.applinker.getEventFromURL();
  var eventType = result.type;
  var params = result.params;

  //Use the eventType and parameters to switch the context.

  }
  else{
  //The task was not opened with application linking; therefore, display 
  //the standard starting page.
  
  }
}