Passer au contenu

SDK JavaScript pour Windows

Télécharger le SDK
Exemple JS W8

Intégration du SDK

Anchor link to

Pour intégrer Pushwoosh dans votre application JS Windows, suivez les étapes ci-dessous.

1. Téléchargez notre package SDK.

2. Ajoutez une référence à PushSDK/Project-Win8.1-WNS/PushSDK.winmd à votre projet
Ou PushSDK/Project-Win10-WNS/PushSDK.winmd si vous développez pour Windows 10

3. Initialisez le service push avec le code suivant :

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. Dans votre fonction app.onactivated, ajoutez ce qui suit :

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);

Fonctionnalités avancées

Anchor link to

Avec les tags, vous pouvez créer un ensemble d’appareils en fonction de différents critères.

1. Créez une liste de tags :

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

2. Envoyez les tags à Pushwoosh :

service.sendTag(keys, values);