> 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="/files/urWSuxUdIjve6aPT3qyL" 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="/files/2tzROJNhblJ81vVBJnVd" 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="/files/nwDLdoUAkfYnRYKAGx1q" alt=""><figcaption></figcaption></figure></div>

### hideLoading()

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

### toast()

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

<div align="left"><figure><img src="/files/RXzAZIHwrVAYEPcmkY2t" alt=""><figcaption></figcaption></figure></div>

### modalSuccess()

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

<div align="left"><figure><img src="/files/a5C4xMepCg0SC52yKiqV" alt=""><figcaption></figcaption></figure></div>

### modalError()

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

<div align="left"><figure><img src="/files/9GifMGXJ47dubLG79S9x" alt=""><figcaption></figcaption></figure></div>

### modalInfo()

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

<div align="left"><figure><img src="/files/y0P1ZRZzJgdAvLJHw2H3" 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="/files/oPN6jrWG6Qs1VqzdnYze" 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,
// }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.quantumbyte.ai/home/quantumbyte-v2.0/3.microsites-1/sdk-mainapp/fitur-fitur.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
