{"_id":"58233e6215f2480f00380f86","githubsync":"","user":"57bc3654b9c7f0220009c77b","parentDoc":null,"__v":0,"category":{"_id":"582318b23b961a0f009516a1","version":"55781fe25129590d003ff4f7","__v":0,"project":"54aa7f773b56130b0056c86e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-11-09T12:38:10.993Z","from_sync":false,"order":5,"slug":"cordova-plugin","title":"Cordova Plugin"},"project":"54aa7f773b56130b0056c86e","version":{"_id":"55781fe25129590d003ff4f7","project":"54aa7f773b56130b0056c86e","forked_from":"54aa7f773b56130b0056c871","__v":6,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z","categories":["55781fe35129590d003ff4f8","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","55781fe35129590d003ff4fb","55781fe35129590d003ff4fc","55781fe35129590d003ff4fd","55781fe35129590d003ff4fe","564bbc7e8841060d00abb2ee","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","582318b23b961a0f009516a1","594a848c9f4771001a43c959"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Developers","version_clean":"2.0.0","version":"2.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-11-09T15:18:58.020Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"To install the Pulsate Cordova Plugin, run the following command in your terminal:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"cordova plugin add https://github.com/PulsateHQ/pulsate-cordova-plugin\",\n      \"language\": \"text\",\n      \"name\": \"Add Plugin\"\n    }\n  ]\n}\n[/block]\n**SDK Versions**\nThe newest Pulsate Cordova Plugin uses the following versions of the Android / iOS SDKs:\n- Android SDK 2.13.0\n- iOS SDK 2.14.1\n\n**Platform support:**\nThe plugin supports iOS and Android platforms.\n\n**Configuring iOS:**\nIn your Xcode project settings, go to capabilities tab and turn on Push Notifications.\n\nThis guide here will help you setting up the Push Notifications - https://pulsate.readme.io/docs/how-to-setup-an-ios-push-cert\n\nFor info about how to properly run Pulsate please read this guide - https://pulsate.readme.io/docs/running-the-pulsate-sdk\n\nThis guide here will help you setup the Android GCM - https://pulsate.readme.io/docs/push-notification-configuration\n\nFor info about how to properly run Pulsate please read this guide - https://pulsate.readme.io/docs/running-the-pulsate-sdk-android\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"How to use the Cordova Plugin - Android\"\n}\n[/block]\nThere are three requirements to successfully run the Pulsate SDK:\n1. Set Application class in AndroidManifest.xml\n2. Proper Authorization Data\n3. Pulsate Session Started\n\nOn Android the Pulsate Manager is created automatically in the MyApplication class. The MyApplication class must be set as the Application name in the AndroidManifest.xml file.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<application\\n        android:name=\\\".MyApplication\\\"\\n        android:hardwareAccelerated=\\\"true\\\"\\n        android:icon=\\\":::at:::mipmap/icon\\\"\\n        android:label=\\\"@string/app_name\\\">\\n</application>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nOn Android to set the Authorization Data you need to call the \"*setAuthorizationData*\" and pass a proper GCM APP ID. Without a proper GCM APP ID Push Notifications will not work.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<button id=\\\"setAuthorizationData\\\">setAuthorizationData</button>\\n$(\\\"#setAuthorizationData\\\").click(function()\\n{ \\n\\twindow.Pulsate.setAuthorizationData(\\\"APP_ID\\\", \\\"APP_KEY\\\", \\\"GCM_APP_ID\\\"); \\n});\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nBefore taking any action the Pulsate Session also must be started. To start the session just call the \"*startPulsateSession*\" or \"*startPulsateSessionForAlias*\" methods.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<button id=\\\"startPulsateSession\\\">Start Session</button>\\n$(\\\"#startPulsateSession\\\").click(function()\\n{\\n  window.Pulsate.startPulsateSession(\\n\\t\\tfunction(result){\\n  \\t\\talert(result);\\n\\t\\t\\twindow.Pulsate.updateFirstName(\\\"John\\n      window.Pulsate.updateLastName(\\\"Smith\\n      window.Pulsate.updateEmail(\\\"john.smith@gmail.com\\\");\\n      window.Pulsate.forceAttributeSync();\\n  \\t}, \\n\\t\\tfunction(error){\\n  \\t\\talert(\\\"error\\\");\\n  \\t});\\n});\\n    \\n<button id=\\\"startPulsateSessionForAlias\\\">Start Session For Alias</button>\\n$(\\\"#startPulsateSessionForAlias\\\").click(function()\\n{\\n\\twindow.Pulsate.startPulsateSessionForAlias(\\\"JohnSmith\\\",\\n\\t\\tfunction(result){\\n      alert(result);\\n      window.Pulsate.updateFirstName(\\\"John\\n      window.Pulsate.updateLastName(\\\"Smith\\n      window.Pulsate.updateEmail(\\\"john.smith@gmail.com\\\");\\n      window.Pulsate.forceAttributeSync();\\n  \\t}, \\n\\t\\tfunction(error){\\n\\t\\t\\talert(\\\"error\\\");\\n    });\\n});\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"How to use the Cordova Plugin - iOS\"\n}\n[/block]\nThere are two requirements to successfully run the Pulsate SDK:\n1. Proper Authorization Data\n2. Pulsate Session Started\n\nOn iOS the Authorization Data and Pulsate Manager should be created as soon as the app starts, for example under the \"*finishLaunching*\" callback in the PulsatePlugin file.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)finishLaunching:(NSNotification *)notification{\\n    launchOptions = notification.userInfo;\\n    NSError *error;\\n    \\n    PULAuthorizationData *data = [[PULAuthorizationData alloc] initWithAppId:@\\\"APP_ID\\\" \\n    andAppKey:@\\\"APP_KEY\\\" validationError:&error];\\n    \\n    pulsateManager = [PULPulsateFactory getInstanceWithAuthorizationData:data \\n    withLocationEnabled:YES withPushEnabled:YES withLaunchOptions:launchOptions \\n    withPulsateAppDelegate:YES andPulsateNotificationDelegate:YES error:&error];\\n}\",\n      \"language\": \"perl\"\n    }\n  ]\n}\n[/block]\nBefore taking any other action the Pulsate Session also should be started. To start the session just call the \"*startPulsateSession*\" or \"*startPulsateSessionForAlias*\" methods.\n\nIn the example below we will have two buttons that start the session on click and after a successful start will set the user data.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<button id=\\\"startPulsateSession\\\">Start Session</button>\\n$(\\\"#startPulsateSession\\\").click(function()\\n{\\n  window.Pulsate.startPulsateSession(\\n\\t\\tfunction(result){\\n  \\t\\talert(result);\\n\\t\\t\\twindow.Pulsate.updateFirstName(\\\"John\\n      window.Pulsate.updateLastName(\\\"Smith\\n      window.Pulsate.updateEmail(\\\"john.smith@gmail.com\\\");\\n      window.Pulsate.forceAttributeSync();\\n  \\t}, \\n\\t\\tfunction(error){\\n  \\t\\talert(\\\"error\\\");\\n  \\t});\\n});\\n    \\n<button id=\\\"startPulsateSessionForAlias\\\">Start Session For Alias</button>\\n$(\\\"#startPulsateSessionForAlias\\\").click(function()\\n{\\n\\twindow.Pulsate.startPulsateSessionForAlias(\\\"JohnSmith\\\",\\n\\t\\tfunction(result){\\n      alert(result);\\n      window.Pulsate.updateFirstName(\\\"John\\n      window.Pulsate.updateLastName(\\\"Smith\\n      window.Pulsate.updateEmail(\\\"john.smith@gmail.com\\\");\\n      window.Pulsate.forceAttributeSync();\\n  \\t}, \\n\\t\\tfunction(error){\\n\\t\\t\\talert(\\\"error\\\");\\n    });\\n});\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Cordova Plugin Methods\"\n}\n[/block]\nAll Plugin methods can be accessed using window.Pulsate. A list of all methods can be found here - https://pulsate.readme.io/docs/cordova-plugin-methods\n\nExamples of how to use some methods can be found below\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<button id=\\\"setDelegates\\\">Set Delegates</button>\\n$(\\\"#setDelegates\\\").click(function()\\n{\\n  window.Pulsate.onBadgeUpdated(function(result){\\n  \\talert('badge updated ' + result);\\n  });\\n\\n  window.Pulsate.onBadgeDecrementBy(function(result){\\n  \\talert('badge decremented ' + result.totalCount + ' - ' + result.badgeDecrement );\\n  });\\n\\n  window.Pulsate.onBadgeIncrementBy(function(result){\\n  \\talert('badge incremented ' + result.totalCount + ' - ' + result.badgeIncrement );\\n  });\\n\\n\\twindow.Pulsate.onUnauthorizedAction(function(result){\\n  \\talert('unauthorized action  ' + result);\\n  });\\n});\\n\\n<button id=\\\"showFeed\\\">Show Feed</button>\\n$(\\\"#showFeed\\\").click(function()\\n{\\n\\twindow.Pulsate.showFeed();\\n});\\n\\n<button id=\\\"setPrivacySubscribed\\\">Subscribe</button>\\n$(\\\"#setPrivacySubscribed\\\").click(function()\\n{\\n\\twindow.Pulsate.setPrivacy(window.Pulsate.PULPrivacyLevelSubscribed); \\n});\\n           \\n<button id=\\\"setPrivacyUnsubscribed\\\">Unsubscribe</button>\\n$(\\\"#setPrivacyUnsubscribed\\\").click(function()\\n{  \\n\\twindow.Pulsate.setPrivacy(window.Pulsate.PULPrivacyLevelUnsubscribed); \\n});\\n\\n<button id=\\\"setGenderMale\\\">Set Gender Male</button>\\n$(\\\"#setGenderMale\\\").click(function()\\n{ \\n\\twindow.Pulsate.updateGender(window.Pulsate.PULUserGenderMale); \\n});\\n     \\n<button id=\\\"setGenderFemale\\\">Set Gender Female</button>\\n$(\\\"#setGenderFemale\\\").click(function()\\n{ \\n\\twindow.Pulsate.updateGender(window.Pulsate.PULUserGenderFemale); \\n});\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"installing-plugin","type":"basic","title":"Installing Cordova Plugin"}

Installing Cordova Plugin


To install the Pulsate Cordova Plugin, run the following command in your terminal: [block:code] { "codes": [ { "code": "cordova plugin add https://github.com/PulsateHQ/pulsate-cordova-plugin", "language": "text", "name": "Add Plugin" } ] } [/block] **SDK Versions** The newest Pulsate Cordova Plugin uses the following versions of the Android / iOS SDKs: - Android SDK 2.13.0 - iOS SDK 2.14.1 **Platform support:** The plugin supports iOS and Android platforms. **Configuring iOS:** In your Xcode project settings, go to capabilities tab and turn on Push Notifications. This guide here will help you setting up the Push Notifications - https://pulsate.readme.io/docs/how-to-setup-an-ios-push-cert For info about how to properly run Pulsate please read this guide - https://pulsate.readme.io/docs/running-the-pulsate-sdk This guide here will help you setup the Android GCM - https://pulsate.readme.io/docs/push-notification-configuration For info about how to properly run Pulsate please read this guide - https://pulsate.readme.io/docs/running-the-pulsate-sdk-android [block:api-header] { "type": "basic", "title": "How to use the Cordova Plugin - Android" } [/block] There are three requirements to successfully run the Pulsate SDK: 1. Set Application class in AndroidManifest.xml 2. Proper Authorization Data 3. Pulsate Session Started On Android the Pulsate Manager is created automatically in the MyApplication class. The MyApplication class must be set as the Application name in the AndroidManifest.xml file. [block:code] { "codes": [ { "code": "<application\n android:name=\".MyApplication\"\n android:hardwareAccelerated=\"true\"\n android:icon=\"@mipmap/icon\"\n android:label=\"@string/app_name\">\n</application>", "language": "xml" } ] } [/block] On Android to set the Authorization Data you need to call the "*setAuthorizationData*" and pass a proper GCM APP ID. Without a proper GCM APP ID Push Notifications will not work. [block:code] { "codes": [ { "code": "<button id=\"setAuthorizationData\">setAuthorizationData</button>\n$(\"#setAuthorizationData\").click(function()\n{ \n\twindow.Pulsate.setAuthorizationData(\"APP_ID\", \"APP_KEY\", \"GCM_APP_ID\"); \n});", "language": "html" } ] } [/block] Before taking any action the Pulsate Session also must be started. To start the session just call the "*startPulsateSession*" or "*startPulsateSessionForAlias*" methods. [block:code] { "codes": [ { "code": "<button id=\"startPulsateSession\">Start Session</button>\n$(\"#startPulsateSession\").click(function()\n{\n window.Pulsate.startPulsateSession(\n\t\tfunction(result){\n \t\talert(result);\n\t\t\twindow.Pulsate.updateFirstName(\"John\n window.Pulsate.updateLastName(\"Smith\n window.Pulsate.updateEmail(\"john.smith@gmail.com\");\n window.Pulsate.forceAttributeSync();\n \t}, \n\t\tfunction(error){\n \t\talert(\"error\");\n \t});\n});\n \n<button id=\"startPulsateSessionForAlias\">Start Session For Alias</button>\n$(\"#startPulsateSessionForAlias\").click(function()\n{\n\twindow.Pulsate.startPulsateSessionForAlias(\"JohnSmith\",\n\t\tfunction(result){\n alert(result);\n window.Pulsate.updateFirstName(\"John\n window.Pulsate.updateLastName(\"Smith\n window.Pulsate.updateEmail(\"john.smith@gmail.com\");\n window.Pulsate.forceAttributeSync();\n \t}, \n\t\tfunction(error){\n\t\t\talert(\"error\");\n });\n});", "language": "html" } ] } [/block] [block:api-header] { "title": "How to use the Cordova Plugin - iOS" } [/block] There are two requirements to successfully run the Pulsate SDK: 1. Proper Authorization Data 2. Pulsate Session Started On iOS the Authorization Data and Pulsate Manager should be created as soon as the app starts, for example under the "*finishLaunching*" callback in the PulsatePlugin file. [block:code] { "codes": [ { "code": "- (void)finishLaunching:(NSNotification *)notification{\n launchOptions = notification.userInfo;\n NSError *error;\n \n PULAuthorizationData *data = [[PULAuthorizationData alloc] initWithAppId:@\"APP_ID\" \n andAppKey:@\"APP_KEY\" validationError:&error];\n \n pulsateManager = [PULPulsateFactory getInstanceWithAuthorizationData:data \n withLocationEnabled:YES withPushEnabled:YES withLaunchOptions:launchOptions \n withPulsateAppDelegate:YES andPulsateNotificationDelegate:YES error:&error];\n}", "language": "perl" } ] } [/block] Before taking any other action the Pulsate Session also should be started. To start the session just call the "*startPulsateSession*" or "*startPulsateSessionForAlias*" methods. In the example below we will have two buttons that start the session on click and after a successful start will set the user data. [block:code] { "codes": [ { "code": "<button id=\"startPulsateSession\">Start Session</button>\n$(\"#startPulsateSession\").click(function()\n{\n window.Pulsate.startPulsateSession(\n\t\tfunction(result){\n \t\talert(result);\n\t\t\twindow.Pulsate.updateFirstName(\"John\n window.Pulsate.updateLastName(\"Smith\n window.Pulsate.updateEmail(\"john.smith@gmail.com\");\n window.Pulsate.forceAttributeSync();\n \t}, \n\t\tfunction(error){\n \t\talert(\"error\");\n \t});\n});\n \n<button id=\"startPulsateSessionForAlias\">Start Session For Alias</button>\n$(\"#startPulsateSessionForAlias\").click(function()\n{\n\twindow.Pulsate.startPulsateSessionForAlias(\"JohnSmith\",\n\t\tfunction(result){\n alert(result);\n window.Pulsate.updateFirstName(\"John\n window.Pulsate.updateLastName(\"Smith\n window.Pulsate.updateEmail(\"john.smith@gmail.com\");\n window.Pulsate.forceAttributeSync();\n \t}, \n\t\tfunction(error){\n\t\t\talert(\"error\");\n });\n});", "language": "html" } ] } [/block] [block:api-header] { "title": "Cordova Plugin Methods" } [/block] All Plugin methods can be accessed using window.Pulsate. A list of all methods can be found here - https://pulsate.readme.io/docs/cordova-plugin-methods Examples of how to use some methods can be found below [block:code] { "codes": [ { "code": "<button id=\"setDelegates\">Set Delegates</button>\n$(\"#setDelegates\").click(function()\n{\n window.Pulsate.onBadgeUpdated(function(result){\n \talert('badge updated ' + result);\n });\n\n window.Pulsate.onBadgeDecrementBy(function(result){\n \talert('badge decremented ' + result.totalCount + ' - ' + result.badgeDecrement );\n });\n\n window.Pulsate.onBadgeIncrementBy(function(result){\n \talert('badge incremented ' + result.totalCount + ' - ' + result.badgeIncrement );\n });\n\n\twindow.Pulsate.onUnauthorizedAction(function(result){\n \talert('unauthorized action ' + result);\n });\n});\n\n<button id=\"showFeed\">Show Feed</button>\n$(\"#showFeed\").click(function()\n{\n\twindow.Pulsate.showFeed();\n});\n\n<button id=\"setPrivacySubscribed\">Subscribe</button>\n$(\"#setPrivacySubscribed\").click(function()\n{\n\twindow.Pulsate.setPrivacy(window.Pulsate.PULPrivacyLevelSubscribed); \n});\n \n<button id=\"setPrivacyUnsubscribed\">Unsubscribe</button>\n$(\"#setPrivacyUnsubscribed\").click(function()\n{ \n\twindow.Pulsate.setPrivacy(window.Pulsate.PULPrivacyLevelUnsubscribed); \n});\n\n<button id=\"setGenderMale\">Set Gender Male</button>\n$(\"#setGenderMale\").click(function()\n{ \n\twindow.Pulsate.updateGender(window.Pulsate.PULUserGenderMale); \n});\n \n<button id=\"setGenderFemale\">Set Gender Female</button>\n$(\"#setGenderFemale\").click(function()\n{ \n\twindow.Pulsate.updateGender(window.Pulsate.PULUserGenderFemale); \n});", "language": "html" } ] } [/block]