कॉर्डोवा प्लगइन एपीआई संदर्भ
var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");
// Should be called before pushwoosh.onDeviceReadydocument.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", projectid: "XXXXXXXXXXXXXXX", serviceName: "XXXX"});
pushwoosh.registerDevice( function(status) { var pushToken = status.pushToken; // handle successful registration here }, function(status) { // handle registration error here });onDeviceReady
Anchor link toPushNotification.prototype.onDeviceReady = function( config )[android, ios, wp8, windows] Pushwoosh प्लगइन को इनिशियलाइज़ करता है और एक स्टार्ट पुश संदेश ट्रिगर करता है। इसे हर ऐप लॉन्च पर कॉल किया जाना चाहिए।
config.appid – Pushwoosh एप्लिकेशन कोड।
config.projectid – Android प्लेटफॉर्म के लिए GCM प्रोजेक्ट नंबर।
config.serviceName – wp8 प्लेटफॉर्म के लिए MPNS सेवा का नाम।
// initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", appid : "PUSHWOOSH_APP_ID", serviceName : "WINDOWS_PHONE_SERVICE". This will trigger all pending push notifications on start.pushwoosh.onDeviceReady({ appid : "XXXXX-XXXXX", projectid: "XXXXXXXXXXXXXXX", serviceName: "XXXX"});registerDevice
Anchor link toPushNotification.prototype.registerDevice = function( success, fail )[android, ios, wp8, windows] डिवाइस को पुश नोटिफिकेशन के लिए पंजीकृत करता है और एक पुश टोकन प्राप्त करता है।
success – सफलता कॉलबैक। पुश टोकन इस कॉलबैक में “status.pushToken” पैरामीटर के रूप में पास किया जाता है।
fail – त्रुटि कॉलबैक।
pushwoosh.registerDevice( function(status) { alert("Registered with push token: " + status.pushToken); }, function(error) { alert("Failed to register: " + error); });unregisterDevice
Anchor link toPushNotification.prototype.unregisterDevice = function( success, fail )[android, ios, wp8, windows] डिवाइस को पुश नोटिफिकेशन प्राप्त करने से अपंजीकृत करता है।
success – सफलता कॉलबैक।
fail – त्रुटि कॉलबैक।
setTags
Anchor link toPushNotification.prototype.setTags = function( config, success, fail )[android, ios, wp8, windows] डिवाइस के लिए टैग सेट करता है।
पैरामीटर्स
config – कस्टम डिवाइस टैग के साथ ऑब्जेक्ट।
success – सफलता कॉलबैक। पुश टोकन इस कॉलबैक में “status.pushToken” पैरामीटर के रूप में पास किया जाता है।
fail – त्रुटि कॉलबैक।
// sets tags: “deviceName” with value “hello” and “deviceId” with value 10pushwoosh.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
Anchor link toPushNotification.prototype.getTags = function( success, fail )[android, ios, wp8, windows] डिफ़ॉल्ट टैग सहित डिवाइस के लिए टैग लौटाता है।
success – सफलता कॉलबैक। पैरामीटर के रूप में टैग प्राप्त करता है।
fail – त्रुटि कॉलबैक।
pushwoosh.getTags( function(tags) { console.warn('tags for the device: ' + JSON.stringify(tags)); }, function(error) { console.warn('get tags error: ' + JSON.stringify(error)); });getPushToken
Anchor link toPushNotification.prototype.getPushToken = function( success )[android, ios, wp8, windows] यदि उपलब्ध हो तो पुश टोकन लौटाता है। ध्यान दें कि टोकन registerDevice फ़ंक्शन कॉलबैक में भी आता है।
success – सफलता कॉलबैक।
pushwoosh.getPushToken( function(token) { console.warn('push token: ' + token); });getPushwooshHWID
Anchor link toPushNotification.prototype.getPushwooshHWID = function( success )[android, ios, wp8, windows] Pushwoosh API के साथ संचार के लिए उपयोग किया जाने वाला Pushwoosh HWID लौटाता है।
success – getPushwooshHWID कॉलबैक।
pushwoosh.getPushwooshHWID( function(token) { console.warn('Pushwoosh HWID: ' + token); });getRemoteNotificationStatus
Anchor link toPushNotification.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
Anchor link toPushNotification.prototype.setApplicationIconBadgeNumber = function( badgeNumber )[android, ios] एप्लिकेशन आइकन बैज नंबर सेट करें।
badgeNumber – आइकन बैज नंबर।
getApplicationIconBadgeNumber
Anchor link toPushNotification.prototype.getApplicationIconBadgeNumber = function( callback )[android, ios] एप्लिकेशन आइकन बैज नंबर लौटाता है।
callback – सफलता कॉलबैक।
pushwoosh.getApplicationIconBadgeNumber(function(badge){ alert(badge);} );addToApplicationIconBadgeNumber
Anchor link toPushNotification.prototype.addToApplicationIconBadgeNumber = function( badgeNumber )[android, ios] एप्लिकेशन आइकन बैज में मान जोड़ता है।
badgeNumber — वृद्धिशील आइकन बैज नंबर।
getLaunchNotification
Anchor link toPushNotification.prototype.getLaunchNotification = function( callback )[android, ios] यदि ऐप पुश नोटिफिकेशन के जवाब में शुरू किया गया था तो पुश नोटिफिकेशन पेलोड लौटाता है, या null।
callback – सफलता कॉलबैक।
clearLaunchNotification
Anchor link toPushNotification.prototype.clearLaunchNotification = function( callback )[android, ios] लॉन्च नोटिफिकेशन को साफ़ करता है, इस कॉल के बाद getLaunchNotification() null लौटाएगा।
setUserId
Anchor link toPushNotification.prototype.setUserId = function( userId )[android, ios] उपयोगकर्ता पहचानकर्ता सेट करता है - एक फेसबुक आईडी, उपयोगकर्ता नाम, ईमेल, या कोई अन्य उपयोगकर्ता आईडी। यह कई उपयोगकर्ता उपकरणों में डेटा और घटनाओं का मिलान करने की अनुमति देता है।
userId – उपयोगकर्ता स्ट्रिंग पहचानकर्ता।
postEvent
Anchor link toPushNotification.prototype.postEvent = function( event, attributes )[android, ios] इन-ऐप संदेशों के लिए ईवेंट पोस्ट करता है। यह Pushwoosh कंट्रोल पैनल में निर्दिष्ट के अनुसार इन-ऐप संदेश प्रदर्शन को ट्रिगर कर सकता है।
event – ट्रिगर करने के लिए इवेंट।
attributes – अतिरिक्त इवेंट विशेषताओं के साथ ऑब्जेक्ट।
pushwoosh.setUserId("XXXXXX");pushwoosh.postEvent("buttonPressed", { "buttonNumber" : 4, "buttonLabel" : "banner" });createLocalNotification
Anchor link toPushNotification.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
Anchor link toPushNotification.prototype.clearLocalNotification = function()[android] createLocalNotification द्वारा बनाए गए सभी लंबित स्थानीय नोटिफिकेशन को साफ़ करता है।
clearNotificationCenter
Anchor link toPushNotification.prototype.clearNotificationCenter = function()[android] एंड्रॉइड नोटिफिकेशन सेंटर में प्रस्तुत सभी नोटिफिकेशन को साफ़ करता है।
setMultiNotificationMode
Anchor link toPushNotification.prototype.setMultiNotificationMode = function( success, fail )[android] एंड्रॉइड नोटिफिकेशन सेंटर में कई नोटिफिकेशन प्रदर्शित करने की अनुमति देता है।
setSingleNotificationMode
Anchor link toPushNotification.prototype.setSingleNotificationMode = function( success,fail )[android] एंड्रॉइड नोटिफिकेशन सेंटर में केवल अंतिम नोटिफिकेशन प्रदर्शित करने की अनुमति देता है।
setSoundType
Anchor link toPushNotification.prototype.setSoundType = function( type, success, fail )[android] आने वाले पुश के लिए डिफ़ॉल्ट ध्वनि सेट करता है।
type – ध्वनि प्रकार (0 – डिफ़ॉल्ट, 1 – कोई ध्वनि नहीं, 2 – हमेशा)।
setVibrateType
Anchor link toPushNotification.prototype.setVibrateType = function(type, success, fail )[android] आने वाले पुश के लिए डिफ़ॉल्ट कंपन मोड सेट करता है।
type – कंपन प्रकार (0 – डिफ़ॉल्ट, 1 – कोई कंपन नहीं, 2 – हमेशा)।
setLightScreenOnNotification
Anchor link toPushNotification.prototype.setLightScreenOnNotification = function( on, success, fail )[android] नोटिफिकेशन आने पर स्क्रीन चालू करता है।
on – स्क्रीन अनलॉक को सक्षम/अक्षम करें (डिफ़ॉल्ट रूप से अक्षम)।
setEnableLED
Anchor link toPushNotification.prototype.setEnableLED = function( on, success, fail )[android] जब नोटिफिकेशन आता है और डिस्प्ले बंद होता है तो एलईडी ब्लिंकिंग को सक्षम करता है।
on – एलईडी ब्लिंक को सक्षम/अक्षम करें (डिफ़ॉल्ट रूप से अक्षम)।
setColorLED
Anchor link toPushNotification.prototype.setColorLED = function( color, success, fail )[android] एलईडी रंग सेट करता है। setEnableLED के साथ उपयोग करें।
color – ARGB पूर्णांक प्रारूप में एलईडी रंग।
getPushHistory
Anchor link toPushNotification.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
Anchor link toPushNotification.prototype.clearPushHistory = function()[android] पुश इतिहास साफ़ करता है।
cancelAllLocalNotifications
Anchor link toPushNotification.prototype.cancelAllLocalNotifications = function( callback )[ios] नोटिफिकेशन सेंटर से सभी स्थानीय नोटिफिकेशन साफ़ करता है।
presentInboxUI
Anchor link to[android, ios] इनबॉक्स स्क्रीन खोलता है।
PushNotification.prototype.presentInboxUI = function()setCommunicationEnabled
Anchor link toPushwoosh के साथ सभी संचार को सक्षम/अक्षम करने वाली एक बाइनरी विधि। बूलियन मान false डिवाइस को पुश नोटिफिकेशन प्राप्त करने से अनसब्सक्राइब करता है और इन-ऐप संदेशों के डाउनलोड को रोकता है। मान true प्रभाव को उलट देता है।
PushNotification.prototype.setCommunicationEnabled = function(enable, success, fail)removeAllDeviceData
Anchor link toडिवाइस के बारे में सभी डेटा हटाता है।
PushNotification.prototype.removeAllDeviceData = function()push-receive
Anchor link to[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)); } });फोरग्राउंड नोटिफिकेशन
Anchor link toडिफ़ॉल्ट रूप से Pushwoosh प्लगइन फोरग्राउंड में नोटिफिकेशन प्रदर्शित नहीं करता है और स्वचालित रूप से push-receive इवेंट को ट्रिगर करता है। इस व्यवहार को नियंत्रित करने के लिए प्लगइन अनुकूलन गाइड देखें।
push-notification
Anchor link to[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 के समान।
additionalAuthorizationOptions
Anchor link to[केवल ios] _अ_तिरिक्त नोटिफिकेशन प्राधिकरण विकल्प प्रदान करता है। 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.});