# Create in-apps with JavaScript

In-app messages are displayed directly within the app interface while a user is already interacting with an app. As a result, users perceive in-apps as less intrusive than push notifications, emails or SMS.

In-app messages always contain images or videos called Rich Media. In-apps can also include formatted text, links, buttons with CTAs, and other data, allowing you to communicate with your app users in engaging forms.

In-Apps are HTML-based and support JavaScript. Pushwoosh SDK injects `pushwoosh` variable that provides the following API:

You can use [`postEvent`](/developer/api-reference/user-centric-api#postevent) method to send a new event directly from In-App JavaScript code.

```javascript
pushwoosh.postEvent(
  'eventName',
  {
    TestAttributeString: 'testString',
    TestAttributeInt: 42,
    TestAttributeList: [123, 456, 'someString'],
    TestAttributeBool: true,
    TestAttributeNull: null,
    TestAttributeDaysAgo: 7,
    TestAttributeDate: new Date()
  },
  function() {
    console.log('Post event success')
  },
  function(error) {
    console.log('Post event failed: ', error)
  }
)
```

You can also use `sendTags` method to set tags for the device from an in-app:

```javascript
pushwoosh.sendTags({
  IntTag: 42,
  BoolTag: true,
  StringTag: 'testString',
  ListTag: ['string1', 'string2']
})
```

To get device tags, use the `getTags` method as follows:

```javascript
pushwoosh.getTags(
  function(tags) {
    console.log('tags: ' + JSON.stringify(tags))
  },
  function(error) {
    console.log('failed to get tags: ' + error)
  }
)
```

If you want to close an in-app from the JavaScript code call `closeInApp()` method:

```
pushwoosh.closeInApp();
```

Or simply use custom scheme URL for the button/link `<a href="pushwoosh://close">`

When sending a push notification with Rich Media, you can get custom data of that push with the following code: `pushwoosh.getCustomData()`

### Custom JavaScript interface

In-App Messages JavaScript functionality can be unlimitedly extended by exposing native Java/Objective-C/Swift methods to JavaScript. This can be achieved with `addJavascriptInterface` methods of Pushwoosh SDK for [iOS](https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/iOS_SDK/Pushwoosh/PushwooshCore/InAppMessages/PWInAppManager.h) and [Android](https://github.com/Pushwoosh/pushwoosh-android-sdk/blob/master/Sources/pushwoosh/src/main/java/com/pushwoosh/inapp/InAppManager.java).