Fitur - Fitur

Init SDK

var sdk = new UtilsSDK(); 

loadUrl()

sdk.loadUrl("https://google.com"); 

setTitle()

Custom AppBar Title di MainApp

sdk.setTitle("Index Data"); 

actionBar()

Custom action bar menu (daftar icon : https://icons8.com/line-awesome)

sdk.actionBar(
    [ 
        // actionBar with native mobile icon & open link on click
        {
            "icon":"whatsapp", // icon-name or absolute url images
            "label":"", // label
            "url":"https://wa.me/+628912", // if not empty [link will be open on-click]
            "onClick":"" // js-handler
        },
        // actionBar with absolute url images & call js handler
        {
            "icon": "https://maxst.icons8.com/vue-static/landings/primary-landings/favs/icons8_fav_32%C3%9732.png",
            "label": "Profile",
            "url": "",
            "onClick": "sdk.toMainApp('/profile');"
        },
    ]
)

selectContact()

Buka daftar kontak di perangkat -> pilih kontak -> hasil balikan (nama & nomor)

// result:
// {
//.    name:"user-1",
//     phones:[+62123xxxx]
//. }
var result = await sdk.selectContact();  
if(result != null){
    var currentName = result.name;
    var currentPhone = result.phones; 
}

requestPermission()

Tampilkan permintaan izin app (fitur ini dapat di gunakan untuk user yg belum mengizinkan / menolak izin tersebut)

// result: 
// [
//  {
//     "type":"location", // location | camera | microphone
//     "status":"granted", // granted | denied | restricted | permanentlyDenied | limited | provisional
//  }
// ] 
var result = await sdk.requestPermission(["location","camera","microphone"]);
for(var r in result){
    console.log("type", r.type)
    console.log("status", r.status)
} 

getCurrentLocation()

Ambil lokasi dan tempat saat ini perangkat

// result: 
// {
//     location: {
//        longitude, latitude, timestamp, accuracy, altitude, altitudeAccuracy, heading, headingAccuracy, speed, speedAccuracy
//     }
//     place:   {
//        name, street, isoCountryCode, country, postalCode, administrativeArea, subAdministrativeArea, locality, subLocality, thoroughfare, subThoroughfare
//     }
// }
var result = await sdk.getCurrentLocation();
if (result.location != null) {
    console.log("location", result.location)
}
if(result.place != null){
    console.log("place", result.place)
} 

gpsService()

Cek gps service aktif atau tidak aktif

// result:
// "enabled" / "disabled"
var result = await sdk.gpsService();
console.log("Gps Service", result) 

openSetting()

Buka pengaturan perangkat

sdk.openSetting();

openBrowser()

Buka eksternal browser

sdk.openBrowser("https://facebook.com");

toPdf()

Webview Page to PDF

// Current Page to PDF
sdk.toPdf(filename="Example_File.pdf")

// External Url to PDF
sdk.toPdf(filename="Google_File.pdf",url="https://google.com",title="Go0Gl3")

// Show actionBar Action Export to PDF
sdk.actionBar([
        {
           "icon": "print",
           "label": "",
           "url": "",
           "onClick": "sdk.toPdf('Example_File.pdf');"
        }
])

clearHistory()

clear / hapus seluruh history navigasi, umumnya bisa di set di halaman home

sdk.clearHistory(); 

onBack()

untuk handle back button di klik pada mainapp

sdk.onBack("home"); // if click go to home
sdk.onBack("back",2); // if click go back 2 step
sdk.onBack("custom", `location.href="/"`); // inject js script on back button pressed
sdk.onBack("custom", `myModal()`, false); // inject js script, and no-clear if keep stay in current page

appbarOverlay()

ubah color overlay appbar

sdk.appbarOverlay(enabled = true, color = "#000000", opacity = 0.5) // show overlay
sdk.appbarOverlay(false); // hide overlay

visibleBackButton()

tampilkan / hilangkan tombol kembali

sdk.visibleBackButton(true); // show back button
sdk.visibleBackButton(false); // hide back button

visibleAppbar()

tampilkan / hilangkan appbar

sdk.visibleAppbar(true); // show appbar
sdk.visibleAppbar(false); // hide appbar

allowPullToRefresh()

izinkan / jangan izinkan tarik untuk refresh halaman

sdk.allowPullToRefresh(true) // allowed
sdk.allowPullToRefresh(false) // not allowed 

closeApp()

tutup webview dan kembali ke home

sdk.closeApp();

showLoading()

sdk.showLoading();

hideLoading()

sdk.hideLoading();

toast()

sdk.toast("Test Toast");

modalSuccess()

sdk.modalSuccess(title, desc, {});

modalError()

sdk.modalError(title, desc, {});

modalInfo()

sdk.modalInfo(title, desc, {});

Custom Button Modal

sdk.modalSuccess(title, desc, {
            isLoading: false, // show loading in modal (default: false)
            dismissible: true, // user can close modal on click outside modal & click back button (default: true)
            enableCloseButton: true, // show close button in modal (default: true)
            customIconUrl: 'https://e7.pngegg.com/pngimages/727/738/png-clipart-computer-icons-question-mark-icon-design-asking-miscellaneous-text.png',
            customButton: [ // add multiple custom button inside modal 
                   {
                      text: "View Detail", // label button
                      disabled: false, // if true, button is disabled
                      backgroundColor: "#ce2121", // background color
                      textColor: "#FFFFFF", // text color
                      borderColor: "#ce2121", // border color
                      onclick: "location.href='/detail.html'", // js handler on click button
                      closeonclick: true, // close modal on click button (default: true)
                   }
              ]
            }
);

toMainApp()

berfungsi untuk membuka page di MainApp

sdk.toMainApp("/home");

// support pages :
// /home = MainApp HomePage (auth,no-auth & prod mode)
// /profile = MainApp profile pages (auth & prod mode)
// /riwayat = MainApp riwayat pages (auth)
// /login = MainApp login pages (no-auth & prod mode)

goBack()

sdk.goBack(step); 

goHome()

sdk.goHome();

goForward()

sdk.goForward(step);

getInfoLoginUser

sdk.InfoLoginUser();

// callback: {
//   "is_login": true / false,
//   "is_login_by_InaPass": true / false,
// }

Last updated