# Phonegap

## API Documentation

### Method Summary

#### executeScript

Execute client side script

**Params**

| Type   | Name   | Summary           | Required |
| ------ | ------ | ----------------- | -------- |
| String | script | script to execute | required |

#### setOnResumeMethod

When resuming an application set a callback method.

**Params**

| Type     | Name     | Summary             | Required |
| -------- | -------- | ------------------- | -------- |
| Function | callback | on success callback | required |

#### setOnPauseMethod

When pausing an application set a callback method.

**Params**

| Type     | Name     | Summary             | Required |
| -------- | -------- | ------------------- | -------- |
| Function | callback | on success callback | required |

#### setOnBackMethod

When hitting the hardware back button set a callback method (Android only).

**Params**

| Type     | Name     | Summary             | Required |
| -------- | -------- | ------------------- | -------- |
| Function | callback | on success callback | required |
|          |          |                     |          |

#### openHrefTag

execute an HREF url string ( opening a phone app or sending an email )

**Params**

| Type   | Name | Summary                                                | Required |
| ------ | ---- | ------------------------------------------------------ | -------- |
| String | url  | example : 'tel:12345678' or 'mailto:<info@servoy.com>' | Required |

#### exit

Exit the application ( not to be confused with Servoy's application.exit method which only exits server session)

#### quitServoySolution

Quit/logout to the main solution (calling this instead of security.logout allows us to re-init plugins again)

## Example Usage

```javascript
//check if phonegap is supported
plugins.svyphonegapPhonegap.executeScript('', [], support);
//add check for back button press
plugins.svyphonegapPhonegap.setOnBackMethod(goBack);

function support() {
	application.output('supported');
	phonegapEnabled = true;
}

function goBack() {
var ans = plugins.dialogs.showQuestionDialog('INFO', 'Exit App?', 'Yes', 'No');
if (ans == 'Yes') {
//exit app
plugins.svyphonegapPhonegap.exit();}
}


//Play a beep sound/ringtone on the phone
function onAction$beep(event) {
	plugins.svyphonegapPhonegap.executeBeep(1);
}

//Vibrate phone for 1000 ms
function onAction$vibrate(event) {
	plugins.svyphonegapPhonegap.executeVibration(1000);	
}

/**
 * Open the device's phone app natively and send it a number to dial
 * @param {JSEvent} event the event that triggered the action
 * @properties={typeid:24,uuid:"90C02F23-BB8E-42E4-8E65-1DE00DD4950E"}
 */
function onAction$openPhone(event) {
	plugins.svyphonegapBrowser.openHrefTag('tel:12345678');
}

/**
 * Open the device's email application natively and try to send an email
 * @param {JSEvent} event the event that triggered the action
 * @properties={typeid:24,uuid:"F22F6985-EE0C-4961-9406-CBDFD840B74E"}
 */
function onAction$sendEmail(event) {
	plugins.svyphonegapBrowser.openHrefTag('mailto:info@servoy.com');
}
```


---

# Agent Instructions: 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:

```
GET https://docs.servoy.com/guides/develop/programming-guide/extensions/modules/svyphonegap/phonegap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
