The response from the master wizard is returned with code 130 using the startActivityForResult method.
The master wizard receives JSON data (e.g., {‘id’:’ 1234567890′, ‘op’: ‘ED434567’}).
String messageStr = new StringBuffer("{'type': 'wizard', 'data':{'id':'1234567890'} }");
Intent intent = new Intent(); intent.setAction("com.anasoft.signatus.signDocument"); intent.putExtra("message", messageStr);
// example {'type': 'wizard', 'data': {'id':'ABCD'} } startActivityForResult(intent,130);
1. Sub-Wizard JavaScript Integration – Detecting External App Launch
let n = getInfo({'code':'NativeIntent'});
If n == 'true' wizard started the native intent.
▪ Signatus API sends information to the wizard indicating that it was launched by an external application.
▪ This is handled using the onSystem function.
▪ The input JSON includes a parameter code with the value 90.
▪ If a sub-wizard is running, information about the ongoing signing process is sent.
function onSystem (data) {
var parameterJson = JSON.parse(data);
var json = parameterJson.parameter;
if (90 === json.code) {
logD('external app call wizard, data:, '+data);
Main.closeNativeIntentWizardRun();
alert("Complete the signing or close the session.");
}
}
2. Notifying External App: Cancel or OK
Cancel message:
Main.closeNativeIntent = function (data) {
let param = {};
param.code=105; // optional number
param.name = "nativeIntent"; // constant
param.status = "cancel"; // constant
param.call="Main.nativeIntent"; // optional function name
param.parameter = {
'param' : 'test_value_abc' // auxiliary optional parameter
}
setSystem(param);
}
OK message:
Main.okNativeIntent = function (data) {
let param = {};
param.code=106;
param.name = "nativeIntent";
param.status = "ok";
param.call="Main.nativeIntent";
param.parameter = {
'param' : 'test_value_xyz' // pomocný parameter
}
setSystem(param);
}
3. Minimizing the App and Launching the Master Wizard (Terminating the Sub-Wizard)
Main.nativeIntent = function (data) {
logD("call nativeIntent, data: "+data);
if(data)
{
var parameterJson = JSON.parse(data);
if (parameterJson.hasOwnProperty('parameter')){
var json = parameterJson['parameter'];
if(json.status == "ok")
{
alert('send info native intent : ok');
cancel({'state':'minimize'});
window.location.href = '../../index.html';
}
else if(json.status == "cancel")
{
alert('send info native intent : cancel');
cancel({'state':'minimize'});
window.location.href = '../../index.html';
}
}
}
};