# कॉर्डोवा प्लगइन एपीआई संदर्भ

```txt title="example"
var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");

// Should be called before pushwoosh.onDeviceReady
document.addEventListener('push-notification', function(event) {
	var notification = event.notification;
	// handle push open here
});

// Initialize Pushwoosh. This will trigger all pending push notifications on start.
pushwoosh.onDeviceReady({
	appid: "XXXXX-XXXXX",
	serviceName: "XXXX"
});

pushwoosh.registerDevice(
	function(status) {
		var pushToken = status.pushToken;
    	// handle successful registration here
  },
  function(status) {
    // handle registration error here
  }
);
```

## onDeviceReady

```javascript
PushNotification.prototype.onDeviceReady = function( config )
```

_\[android, ios, wp8, windows]_
पुशवूश प्लगइन को इनिशियलाइज़ करता है और एक स्टार्ट पुश संदेश ट्रिगर करता है। इसे हर ऐप लॉन्च पर कॉल किया जाना चाहिए।

`config.appid` – पुशवूश एप्लिकेशन कोड।

`config.serviceName` – wp8 प्लेटफॉर्म के लिए MPNS सेवा का नाम।

```txt title="example"
// initialize Pushwoosh with appid : "PUSHWOOSH_APP_ID", serviceName : "WINDOWS_PHONE_SERVICE". This will trigger all pending push notifications on start.
pushwoosh.onDeviceReady({
    appid : "XXXXX-XXXXX",
    serviceName: "XXXX"
});
```

## registerDevice

```javascript
PushNotification.prototype.registerDevice = function( success, fail )
```

_\[android, ios, wp8, windows]_
डिवाइस को पुश नोटिफिकेशन के लिए पंजीकृत करता है और एक पुश टोकन प्राप्त करता है।

`success` – सफलता कॉलबैक। पुश टोकन इस कॉलबैक में “status.pushToken” पैरामीटर के रूप में पास किया जाता है

`fail` – त्रुटि कॉलबैक

```txt title="example"
pushwoosh.registerDevice(
    function(status) {
        alert("Registered with push token: " + status.pushToken);
    },
    function(error) {
        alert("Failed to register: " +  error);
    }
);
```

## unregisterDevice

```javascript
PushNotification.prototype.unregisterDevice = function(	success, fail	)
```

_\[android, ios, wp8, windows]_
डिवाइस को पुश नोटिफिकेशन प्राप्त करने से अपंजीकृत करता है।

`success` – सफलता कॉलबैक

`fail` – त्रुटि कॉलबैक

## setTags

```javascript
PushNotification.prototype.setTags = function(	config, success, fail	)
```

_\[android, ios, wp8, windows]_
डिवाइस के लिए टैग सेट करता है।

**पैरामीटर्स**

`config` – कस्टम डिवाइस टैग के साथ ऑब्जेक्ट

`success` – सफलता कॉलबैक। पुश टोकन इस कॉलबैक में “status.pushToken” पैरामीटर के रूप में पास किया जाता है

`fail` – त्रुटि कॉलबैक

```txt title="example"
// sets tags: “deviceName” with value “hello” and “deviceId” with value 10
pushwoosh.setTags({deviceName:"hello", deviceId:10},
    function() {
        console.warn('setTags success');
    },
    function(error) {
        console.warn('setTags failed');
    }
);

// sets list tags "MyTag" with values (array) "hello", "world"
pushwoosh.setTags({"MyTag":["hello", "world"]});
```

## getTags

```javascript
PushNotification.prototype.getTags = function(	success, fail	)
```

_\[android, ios, wp8, windows]_
डिवाइस के लिए डिफ़ॉल्ट टैग सहित टैग लौटाता है।

`success` – सफलता कॉलबैक। पैरामीटर के रूप में टैग प्राप्त करता है

`fail` – त्रुटि कॉलबैक

```javascript
pushwoosh.getTags(
    function(tags) {
        console.warn('tags for the device: ' + JSON.stringify(tags));
    },
    function(error) {
        console.warn('get tags error: ' + JSON.stringify(error));
    }
);
```

## getPushToken

```javascript
PushNotification.prototype.getPushToken = function(	success	)
```

_\[android, ios, wp8, windows]_
यदि उपलब्ध हो तो पुश टोकन लौटाता है। ध्यान दें कि टोकन registerDevice फ़ंक्शन कॉलबैक में भी आता है।

`success` – सफलता कॉलबैक।

```javascript
pushwoosh.getPushToken(
    function(token) {
        console.warn('push token: ' + token);
    }
);
```

## getPushwooshHWID

```javascript
PushNotification.prototype.getPushwooshHWID = function(	success	)
```

_\[android, ios, wp8, windows]_
Pushwoosh API के साथ संचार के लिए उपयोग किया जाने वाला Pushwoosh HWID लौटाता है।

`success` – getPushwooshHWID कॉलबैक

```
pushwoosh.getPushwooshHWID(
    function(token) {
        console.warn('Pushwoosh HWID: ' + token);
    }
);
```

## getRemoteNotificationStatus

```javascript
PushNotification.prototype.getRemoteNotificationStatus = function(	callback, error	)
```

_\[android, ios]_
पुश नोटिफिकेशन अनुमतियों की विस्तृत स्थिति लौटाता है।

`callback` – सफलता कॉलबैक। निम्नलिखित गुणों के साथ ऑब्जेक्ट प्राप्त करता है:

```
{
  "enabled" : notificaions enabled flag.
  "pushBadge" : badges permission granted. (iOS only)
  "pushAlert" : alert permission granted. (iOS only)
  "pushSound" : sound permission granted. (iOS only)
}
```

`error` — त्रुटि कॉलबैक

## setApplicationIconBadgeNumber

```javascript
PushNotification.prototype.setApplicationIconBadgeNumber = function(	badgeNumber	)
```

_\[android, ios]_
एप्लिकेशन आइकन बैज नंबर सेट करें।

`badgeNumber` – आइकन बैज नंबर

## getApplicationIconBadgeNumber

```javascript
PushNotification.prototype.getApplicationIconBadgeNumber = function(	callback	)
```

_\[android, ios]_
एप्लिकेशन आइकन बैज नंबर लौटाता है।

`callback` – सफलता कॉलबैक

```
pushwoosh.getApplicationIconBadgeNumber(function(badge){ alert(badge);} );
```

## addToApplicationIconBadgeNumber

```javascript
PushNotification.prototype.addToApplicationIconBadgeNumber = function( badgeNumber )
```

_\[android, ios]_
एप्लिकेशन आइकन बैज में मान जोड़ता है।

`badgeNumber` — वृद्धिशील आइकन बैज नंबर

## getLaunchNotification

```javascript
PushNotification.prototype.getLaunchNotification = function(	callback	)
```

_\[android, ios]_
यदि ऐप पुश नोटिफिकेशन के जवाब में शुरू किया गया था तो पुश नोटिफिकेशन पेलोड लौटाता है, अन्यथा null।

`callback` – सफलता कॉलबैक

## clearLaunchNotification

```javascript
PushNotification.prototype.clearLaunchNotification = function(	callback	)
```

_\[android, ios]_
लॉन्च नोटिफिकेशन को साफ़ करता है, इस कॉल के बाद `getLaunchNotification()` null लौटाएगा।

## setUserId

```javascript
PushNotification.prototype.setUserId = function(	userId	)
```

_\[android, ios]_
उपयोगकर्ता पहचानकर्ता सेट करता है– एक फेसबुक आईडी, उपयोगकर्ता नाम, ईमेल, या कोई अन्य उपयोगकर्ता आईडी। यह डेटा और ईवेंट को कई उपयोगकर्ता उपकरणों में मिलान करने की अनुमति देता है।

`userId` – उपयोगकर्ता स्ट्रिंग पहचानकर्ता

## postEvent

```javascript
PushNotification.prototype.postEvent = function( event, attributes )
```

_\[android, ios]_
इन-ऐप संदेशों के लिए ईवेंट पोस्ट करता है। यह पुशवूश कंट्रोल पैनल में निर्दिष्ट के अनुसार इन-ऐप संदेश प्रदर्शन को ट्रिगर कर सकता है।

`event` – ट्रिगर करने के लिए ईवेंट

`attributes` – अतिरिक्त ईवेंट विशेषताओं के साथ ऑब्जेक्ट

```
pushwoosh.setUserId("XXXXXX");
pushwoosh.postEvent("buttonPressed", { "buttonNumber" : 4, "buttonLabel" : "banner" });
```

## createLocalNotification

```javascript
PushNotification.prototype.createLocalNotification = function( config, success, fail )
```

_\[android, ios]_
स्थानीय नोटिफिकेशन शेड्यूल करता है।

`config.msg` – नोटिफिकेशन संदेश

`config.seconds` – सेकंड में नोटिफिकेशन देरी

`config.userData` – नोटिफिकेशन में पास करने के लिए अतिरिक्त डेटा

`success` – सफलता कॉलबैक

`fail` – त्रुटि कॉलबैक

```
pushwoosh.createLocalNotification({msg:"Your pumpkins are ready!", seconds:30, userData:{}})
```

## clearLocalNotification

```javascript
PushNotification.prototype.clearLocalNotification = function()
```

_\[android]_
`createLocalNotification` द्वारा बनाए गए सभी लंबित स्थानीय नोटिफिकेशन को साफ़ करता है

## clearNotificationCenter

```javascript
PushNotification.prototype.clearNotificationCenter = function()
```

_\[android]_
एंड्रॉइड नोटिफिकेशन सेंटर में प्रस्तुत सभी नोटिफिकेशन को साफ़ करता है।

## setMultiNotificationMode

```javascript
PushNotification.prototype.setMultiNotificationMode = function( success, fail )
```

_\[android]_
एंड्रॉइड नोटिफिकेशन सेंटर में कई नोटिफिकेशन प्रदर्शित करने की अनुमति देता है।

## setSingleNotificationMode

```javascript
PushNotification.prototype.setSingleNotificationMode = function(	success,
fail	)
```

_\[android]_
एंड्रॉइड नोटिफिकेशन सेंटर में केवल अंतिम नोटिफिकेशन प्रदर्शित करने की अनुमति देता है।

## setSoundType

```javascript
PushNotification.prototype.setSoundType = function( type, success, fail )
```

_\[android]_
आने वाले पुश के लिए डिफ़ॉल्ट ध्वनि सेट करता है।

`type` – ध्वनि प्रकार (0 – डिफ़ॉल्ट, 1 – कोई ध्वनि नहीं, 2 – हमेशा)

## setVibrateType

```javascript
PushNotification.prototype.setVibrateType = function(type, success, fail )
```

_\[android]_
आने वाले पुश के लिए डिफ़ॉल्ट कंपन मोड सेट करता है।

`type` – कंपन प्रकार (0 – डिफ़ॉल्ट, 1 – कोई कंपन नहीं, 2 – हमेशा)

## setLightScreenOnNotification

```javascript
PushNotification.prototype.setLightScreenOnNotification = function( on, success, fail )
```

_\[android]_
नोटिफिकेशन आने पर स्क्रीन चालू करता है।

`on` – स्क्रीन अनलॉक सक्षम/अक्षम करें (डिफ़ॉल्ट रूप से अक्षम)

## setEnableLED

```javascript
PushNotification.prototype.setEnableLED = function( on, success, fail )
```

_\[android]_
जब नोटिफिकेशन आता है और डिस्प्ले बंद होता है तो एलईडी ब्लिंकिंग को सक्षम करता है।

`on` – एलईडी ब्लिंक सक्षम/अक्षम करें (डिफ़ॉल्ट रूप से अक्षम)

## setColorLED

```javascript
PushNotification.prototype.setColorLED = function( color, success, fail )
```

_\[android]_
एलईडी रंग सेट करता है। [setEnableLED](#setenableled) के साथ प्रयोग करें।

`color` – ARGB पूर्णांक प्रारूप में एलईडी रंग

## getPushHistory

```javascript
PushNotification.prototype.getPushHistory = function(	success	)
```

_\[android]_
प्राप्त पुश नोटिफिकेशन की ऐरे लौटाता है।

`success` – सफलता कॉलबैक

```
pushwoosh.getPushHistory(function(pushHistory) {
    if(pushHistory.length == 0)
        alert("no push history");
    else
        alert(JSON.stringify(pushHistory));
});

pushwoosh.clearPushHistory();
```

## clearPushHistory

```javascript
PushNotification.prototype.clearPushHistory = function()
```

_\[android]_
पुश हिस्ट्री साफ़ करता है।

## cancelAllLocalNotifications

```javascript
PushNotification.prototype.cancelAllLocalNotifications = function( callback )
```

_\[ios]_
नोटिफिकेशन सेंटर से सभी स्थानीय नोटिफिकेशन साफ़ करता है।

## presentInboxUI

_\[android, ios]_
[इनबॉक्स](/hi/developer/guides/message-inbox/mobile-message-inbox) स्क्रीन खोलता है।

```javascript
PushNotification.prototype.presentInboxUI = function()
```

## setCommunicationEnabled

Pushwoosh के साथ सभी संचार को सक्षम/अक्षम करने वाला एक बाइनरी तरीका। बूलियन मान **false** डिवाइस को पुश नोटिफिकेशन प्राप्त करने से अनसब्सक्राइब करता है और इन-ऐप संदेशों का डाउनलोड बंद कर देता है। मान **true** प्रभाव को उलट देता है।

```javascript
PushNotification.prototype.setCommunicationEnabled = function(enable, success, fail)
```

## removeAllDeviceData

डिवाइस के बारे में सभी डेटा हटा देता है।

```javascript
PushNotification.prototype.removeAllDeviceData = function()
```

## push-receive

_\[android, ios]_
पुश नोटिफिकेशन प्राप्ति ईवेंट। यह तब फायर होता है जब एप्लिकेशन फोरग्राउंड या बैकग्राउंड में पुश नोटिफिकेशन प्राप्त करता है। बंद एप्लिकेशन इस ईवेंट को प्राप्त नहीं करते हैं।

**ईवेंट गुण**

`message` – (`string`) पुश नोटिफिकेशन संदेश

`userdata` – (`object`/`array`) पुश नोटिफिकेशन कस्टम डेटा

`onStart` – (`boolean`) क्या लॉन्च नोटिफिकेशन है

`foreground` – (`boolean`) क्या नोटिफिकेशन फोरग्राउंड में प्राप्त हुआ है

`android` – (`object`) एंड्रॉइड विशिष्ट नोटिफिकेशन पेलोड

`ios` – (`object`) iOS विशिष्ट नोटिफिकेशन पेलोड

`windows` – (`object`) विंडोज विशिष्ट नोटिफिकेशन पेलोड

```
document.addEventListener('push-receive',
	function(event) {
		var userData = event.notification.userdata;

		if (typeof(userData) != "undefined") {
			// handle custom notification data
			console.warn('user data: ' + JSON.stringify(userData));
		}
	}
);
```

## फोरग्राउंड नोटिफिकेशन

डिफ़ॉल्ट रूप से पुशवूश प्लगइन फोरग्राउंड में नोटिफिकेशन प्रदर्शित नहीं करता है और स्वचालित रूप से `push-receive` ईवेंट को ट्रिगर करता है। इस व्यवहार को नियंत्रित करने के लिए [प्लगइन कस्टमाइज़ेशन गाइड](/hi/developer/pushwoosh-sdk/cross-platform-frameworks/cordova/customizing-cordova-plugin/) देखें।

### push-notification

_\[android, ios, wp8, windows]_
पुश नोटिफिकेशन स्वीकृति ईवेंट। यह तब फायर होता है जब उपयोगकर्ता पुश नोटिफिकेशन पर टैप करता है।

```
document.addEventListener('push-notification',
	function(event) {
		var message = event.notification.message;
		var userData = event.notification.userdata;

		if (typeof(userData) != "undefined") {
			console.warn('user data: ' + JSON.stringify(userData));
		}
	}
);
```

**ईवेंट गुण**

[push-receive](#push-receive) के समान

### additionalAuthorizationOptions

_\[ios only]_
_अ_तिरिक्त [नोटिफिकेशन प्राधिकरण विकल्प](https://developer.apple.com/documentation/usernotifications/unauthorizationoptions?language=objc) प्रदान करता है। इसे **registerDevice** को कॉल करने से पहले कॉल किया जाना चाहिए।

```
pushwoosh.additionalAuthorizationOptions({ 
	"UNAuthorizationOptionCriticalAlert" : 1,
	"UNAuthorizationOptionProvisional": 0 // set 0 or don't specify the option if you don't want to add it to your app. 
});
```