Skip to content

Client API

Usage

<script src="https://cdn.bizstore.io/bizapp-0.0.2.min.js"></script>

BizApp.login(options, callback)

Initiate user login with server

Parameter Description Default Required
options.url The URL that handle login request True
callback Callback of result returned from server False

Example:

BizApp.login({ url: "https://mybizapp.com/api/login" }, function(error, userData) {
  if (error) {
    console.log("Login failed: " + error);
    return;
  }
  console.log("Login success: " + userData);
});

Notes:

  • userData is the data sent from the server side in the login callback (Check the documentation in Server API section for more info)

BizApp.payToWallet(options, callback)

Pay to a wallet address

Parameter Description Default Required
options.address Address to pay to (Only testnet addresses are allowed in developer mode) True
options.amount Amount to pay, in unit of 1/100000000 True
options.message Message to include "" False
options.identifier Identifier to be attached with the transaction for verification purpose on server side (Max 8 chars) False
callback Callback with result and transaction information False

Example:

var options = {
  address: "yewLaSjEiziHhqgRwmyTomMNfiQm9h4SNM",
  amount: 100000000, // 1 TRVC
  message: "Payment for BizApp",
  identifier: "446f7261"
};

BizApp.payToWallet(options, function(error, result) {
  if (error) {
    console.log("Payment failed: " + error);
    return;
  }
  console.log("Payment success: " + result);
});

Callback Example:

{
  amount: 100000000
  message: "Payment for BizApp"
  timestamp: 1523752860
  toAddress: "yewLaSjEiziHhqgRwmyTomMNfiQm9h4SNM"
  txid: "8671fdfd682c47ff1f6ee29bf74a726c21022311c749403450d31eec9c67ba45"
}

Notes:

  • Only testnet addresses are allowed in developer mode
  • 1 TRVC = 100000000 unit

BizApp.setBackHandler(options, callback)

Set a custom handler when back button is pressed. By default, tapping on back button will go to the previous page.

Parameter Description Default Required
options.backHandler Custom handler when back button is pressed True

Example:

var customBackHandler = function() {
  window.history.back();
}

BizApp.setBackHandler({
  backHandler: customBackHandler
});

BizApp.openExternalLink(options, callback)

Open external link in new tab or system browser.

Parameter Description Default Required
options.url The URL to open True
callback Callback with result of the external link. true if external link open successfully, false otherwise False

Example:

BizApp.openExternalLink({ url: "https://trivecoin.org" }, function(err, res) {
  console.log(res);
});

BizApp.getSDKVersion(callback)

Get the SDK version of the client wallet. Useful to detect old versions and force update.

Parameter Description Default Required
callback Callback with the version label (Example: 0.0.3) False

Example:

BizApp.getSDKVersion(function(err, res) {
  console.log(res); // 0.0.3
});

BizApp.isMethodAvailable(methodName, callback)

Check if a method is available before calling for backward compatibility.

Parameter Description Default Required
methodName The method name to test True
callback Callback with result of true if the method is available, false otherwise False

Example:

BizApp.isMethodAvailable("isMethodAvailable", function(err, res) {
  console.log(res); // true
});