import { UnviredCordovaSDK } from '@ionic-native/unvired-cordova-sdk/ngx';
constructor(private unviredSDK: UnviredCordovaSDK) { }
...
let loginParameters = new LoginParameters()
loginParameters.appName = 'UNVIRED_DIGITAL_FORMS'
loginParameters.metadataPath = '../assets/metadata.json'
let loginResult: LoginResult
try {
loginResult = await this.unviredSDK.login(loginParameters)
}
catch (error) {
this.unviredSDK.logError("AppComponent", "Initialize", "Error during login: " + error)
}
switch (loginResult.type) {
case LoginListenerType.auth_activation_required:
try {
let loginParameters = new LoginParameters();
loginParameters.url = '<UMP_URL>';
loginParameters.company = '<Company>';
loginParameters.username = '<Username>';
loginParameters.password = '<Password>';
loginParameters.loginType = LoginType.unvired;
let authenticateActivateResult: AuthenticateActivateResult = await this.unviredSDK.authenticateAndActivate(loginParameters);
if (authenticateActivateResult.type === AuthenticateAndActivateResultType.auth_activation_success) {
} else if (authenticateActivateResult.type === AuthenticateAndActivateResultType.auth_activation_error) {
console.log("Error during login: " + authenticateActivateResult.error)
} catch (error) {
this.unviredSDK.logError('LoginPage', 'auth_activation_required', 'ERROR: ' + error);
}
break;
case LoginListenerType.app_requires_login:
try {
let loginParameters = new LoginParameters()
loginParameters.username = '<Username>';
loginParameters.password = '<Password>';
let authenticateLocalResult: AuthenticateLocalResult = await this.unviredSDK.authenticateLocal(loginParameters);
if (authenticateLocalResult.type === AuthenticateLocalResultType.login_success) {
} else if (authenticateLocalResult.type === AuthenticateLocalResultType.login_error) {
console.log("Error during local login: " + authenticateActivateResult.error)
} catch (error) {
this.unviredSDK.logError('LoginPage', 'app_requires_login', 'ERROR: ' + error);
}
break;
case login_success:
break;
}
let result = await this.unviredSDK.syncForeground(RequestType.QUERY, null, {"CUSTOMER_HEADER": {"field1" : "value1", "field2" : "value2"}}, 'UNVIRED_DIGITAL_FORMS_PA_MOBILE_GET_USERS', true)
let result = await this.unviredSDK.syncBackground(RequestType.QUERY, null, inputObj, 'UNVIRED_DIGITAL_FORMS_PA_MOBILE_GET_USERS', 'INPUT_GET_USERS', 'GUID', false)
this.unviredSDK.registerNotifListener().subscribe( data => {
switch (data.type) {
case NotificationListenerType.dataSend:
break;
case NotificationListenerType.dataChanged:
break;
case NotificationListenerType.dataReceived:
break;
.
.
.
}})
this.unviredsdk.dbInsert("CUSTOMER_HEADER", {"NAME":"USER","NO":"0039"}, true);
this.unviredSDK.dbUpdate('CUSTOMER_HEADER', {"NAME":"UPDATED_USER","NO":"UPDATED_NO"}, "FORM_ID = '5caed815892215034dacad56'")
this.unviredSDK.dbDelete('CUSTOMER_HEADER', "FORM_ID = '5caed815892215034dacad56'")
this.unviredSDK.dbExecuteStatement('SELECT * FROM CUSTOMER_HEADER WHERE CUSTOMER_ID = "0039"')