# Windows Javascript SDK

[**Download SDK**](https://github.com/Pushwoosh/pushwoosh-windows-sdk)\
[**W8 JS Sample**](https://github.com/Pushwoosh/pushwoosh-windows-sdk/tree/master/Samples/Win8.1JS)

<Aside>
#### Supports Windows 8.1, Windows 10
</Aside>

## SDK Integration

<Aside type="note">
You can use an emulator while working with push notifications.
</Aside>

To integrate Pushwoosh into your Windows JS application, follow the steps below.

**1.** Download our SDK package.

**2.** Add reference to **PushSDK/Project-Win8.1-WNS/PushSDK.winmd** to your project\
Or **PushSDK/Project-Win10-WNS/PushSDK.winmd** if you develop for Windows 10

**3.** Initialize push service with the following code:

```javascript
var service = new PushSDK.NotificationService.getCurrent("YOUR_PUSHWOOSH_APP_ID");
 
service.ononpushaccepted = function (args) {
    //code to handle push notification
    //display push notification payload for test only
    var md = new Windows.UI.Popups.MessageDialog(args.toString());
    md.showAsync()
}
 
service.ononpushtokenreceived = function (pushToken) {
    //code to handle push token
}
 
service.ononpushtokenfailed = function (error) {
    //code to handle push subscription failure
}
 
service.subscribeToPushService();
```

**4.** In your **app.onactivated** function add the following:

```javascript
app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                // TODO: This application has been newly launched. Initialize
                // your application here.
 
                //Handle start push
                PushSDK.NotificationService.handleStartPush(args.detail.arguments);
```

<Aside type="caution" title=" Important"> 
If you plan to use Toast notifications, please make sure Toast notifications are swithced on in your application project. Go to Application UI tab in manifest settings, and set **Toast Capable** to **Yes**. Otherwise, Toast notifications will not work on the device.
</Aside>

<img src="/windows-windows-javascript-sdk-1.webp" alt=""/>

## Advanced features

### Tags

With tags, you can create a set of devices based on different criteria.

**1.** Create a list of tags:

```javascript
var keys = ["name1", "name2"];
var values = ["value1", "value2"];
```

**2.** Send tags to Pushwoosh:

```javascript
service.sendTag(keys, values);
```