> For the complete documentation index, see [llms.txt](https://docs.quantumbyte.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quantumbyte.ai/home/quantumbyte-v2.0/3.microsites-1/sdk-mainapp/fitur-fitur.md).

# Fitur - Fitur

### Init SDK

```javascript
var sdk = new UtilsSDK(); 
```

### loadUrl()

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

### setTitle()

Custom AppBar Title di MainApp

```javascript
sdk.setTitle("Index Data"); 
```

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-67cbe31423e382bc0d3a8438b3a5997342ae7d3f%2Fimage%20(174).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### actionBar()

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

```javascript
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');"
        },
    ]
)
```

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-29450eaadc3ba4049307f0e5ea021391c85d8b56%2Fimage%20(175).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### selectContact()

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

```javascript
// 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)

```javascript
// 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

```javascript
// 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)
} 
```

### getIpMainapp()

Get Ip pada Mainapp Mobile

```typescript
// result
// 192.168.1.1
var result = await sdk.getIpMainapp();
```

### gpsService()

Cek gps service aktif atau tidak aktif

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

### openSetting()

Buka pengaturan perangkat

```javascript
sdk.openSetting();
```

### openBrowser()

Buka eksternal browser

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

### toPdf()

Webview Page to PDF

```javascript
// 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

```javascript
sdk.clearHistory(); 
```

### onBack()

untuk handle back button di klik pada mainapp

```javascript
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

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

### visibleBackButton()

tampilkan / hilangkan tombol kembali

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

### visibleAppbar()

tampilkan / hilangkan appbar

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

### allowPullToRefresh()

izinkan / jangan izinkan tarik untuk refresh halaman

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

### closeApp()

tutup webview dan kembali ke home

```javascript
sdk.closeApp();
```

### showLoading()

```javascript
sdk.showLoading();
```

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-b8794c07a87645f6f9d9e8fca9f62326a802705a%2Fimage%20(176).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### hideLoading()

```javascript
sdk.hideLoading();
```

### toast()

```javascript
sdk.toast("Test Toast");
```

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-67b6cf5c3038f509b59fb85da46234e82ef0041d%2Fimage%20(177).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### modalSuccess()

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

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-0fce56eab83d693719e97cdfd96376afcfa6abc0%2Fimage%20(178).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### modalError()

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

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-17658579ec4f6584de91a5bf235c34985c08b49f%2Fimage%20(179).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### modalInfo()

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

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-d80222f29a796b0cfafe21718cdeab8775bdaff6%2Fimage%20(180).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### Custom Button Modal

```javascript
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)
                   }
              ]
            }
);
```

<div align="left"><figure><img src="https://3956894092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWmc9IGdzSxwzSIEHL6y%2Fuploads%2Fgit-blob-a33fcb166e4d9f3632ef502b9ca387f3de82af82%2Fimage%20(181).png?alt=media" alt=""><figcaption></figcaption></figure></div>

### toMainApp()

berfungsi untuk membuka page di MainApp

```javascript
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)
// /faq = MainApp FAQ page (auth,no-auth & prod mode)
// /faq/:id = MainApp FAQ Detail page (replace id with id of FAQ) (auth,no-auth & prod mode)
// /chat = MainApp Chat List pages (no-auth & prod mode)
// /chat_room = MainApp Chat Room pages (no-auth & prod mode)
// /form_pengaduan = MainApp chat pages (no-auth & prod mode)
```

### goBack()

```javascript
sdk.goBack(step); 
```

### goHome()

```javascript
sdk.goHome();
```

### goForward()

```javascript
sdk.goForward(step);
```

## getInfoLoginUser

```javascript
sdk.InfoLoginUser();

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