# News: liff.isApiAvailable() added to LIFF v2

liff.isApiAvailable() added to LIFF v2

We added the method liff.isApiAvailable() to LIFF v2. This method checks whether a specified API can be used in the environment where the LIFF app was launched.

Note

The number of APIs you can specify is limited. Currently, you can only specify liff.shareTargetPicker(). We'll notify you when more APIs can be checked with liff.isApiAvailable() in the future.

# Check if share target picker is available

By executing liff.isApiAvailable() before you execute liff.shareTargetPicker(), you can avoid the user getting an error message on their screen if the share target picker isn't available in their device environment.

if (liff.isApiAvailable('shareTargetPicker')) {
  liff.shareTargetPicker([
    {
      type: "text",
      text: "Hello, World!"
    }
  ])
    .then(
      alert("ShareTargetPicker was launched")
    ).catch(function(res) {
      alert("Failed to launch ShareTargetPicker")
    })
}

Learn more from liff.isApiAvailable() in the LIFF v2 API reference.