{"id":20340183,"url":"https://github.com/webengage/cordova-plugin","last_synced_at":"2025-04-11T23:16:50.118Z","repository":{"id":18211834,"uuid":"83808422","full_name":"WebEngage/cordova-plugin","owner":"WebEngage","description":"Cordova/PhoneGap plugin for integrating WebEngage's native SDKs with hybrid Cordova/PhoneGap platforms","archived":false,"fork":false,"pushed_at":"2024-08-28T11:53:05.000Z","size":472,"stargazers_count":1,"open_issues_count":3,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T23:16:44.623Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebEngage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-03T14:46:47.000Z","updated_at":"2024-08-28T11:53:05.000Z","dependencies_parsed_at":"2023-10-11T04:22:01.728Z","dependency_job_id":"fa21550b-7675-4906-976a-d946e29daae6","html_url":"https://github.com/WebEngage/cordova-plugin","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fcordova-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fcordova-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fcordova-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fcordova-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebEngage","download_url":"https://codeload.github.com/WebEngage/cordova-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492885,"owners_count":21113163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T21:20:07.019Z","updated_at":"2025-04-11T23:16:50.094Z","avatar_url":"https://github.com/WebEngage.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebEngage Plugin for Cordova/Phonegap\n\n\nThe Cordova SDK was tested on Cordova v8.0.0 for Cordova android ^7.0.0 and Cordova iOS ^4.5.5. Read the complete documentation at [WebEngage Cordova/PhoneGap Plugin Documentation](http://docs.webengage.com/docs/cordova-integration)\n\n\n## Installation\n\n```\ncordova plugin add cordova-plugin-webengage --fetch\n```\n\n\n## Integration\n\nAdd the following details in your `config.xml` file.\n\n```xml\n\u003cwidget ... xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n    ...\n    \u003c!-- For Android --\u003e\n    \u003cplatform name=\"android\"\u003e\n        \u003cconfig-file parent=\"/manifest/application\" target=\"AndroidManifest.xml\"\u003e\n            ...\n            \u003cmeta-data android:name=\"com.webengage.sdk.android.key\" android:value=\"YOUR-LICENSE-CODE\" /\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n\n    \u003c!-- For iOS --\u003e\n    \u003cplatform name=\"ios\"\u003e\n        ...\n        \u003cconfig-file parent=\"WEGLicenseCode\" target=\"*-Info.plist\"\u003e\n            \u003cstring\u003eYOUR-LICENSE-CODE\u003c/string\u003e\n        \u003c/config-file\u003e\n    \u003c.platform\u003e\n\n\u003c/widget\u003e\n```\n\n**Note:** Replace 'YOUR-LICENSE-CODE' with your WebEngage License Code.\n\n\n## Initialization\n\nInitialize WebEngage SDK in your `wwww/js/index.js` file.\n\n```javascript\nvar app = {\n    ...\n    onDeviceReady: function() {\n        ...\n\n        // WebEngage initialization\n        webengage.engage();\n    }\n}\n```\n\n\n## Configurations\n\n### 1. Enable/Disable SDK Logs\n\nAdd the following tags in your `config.xml` file.\n\n```xml\n\u003cwidget ... \u003e\n    ...\n    \u003c!-- For Android --\u003e\n    \u003cplatform name=\"android\"\u003e\n        \u003cconfig-file parent=\"/manifest/application\" target=\"AndroidManifest.xml\"\u003e\n            ...\n            \u003cmeta-data android:name=\"com.webengage.sdk.android.debug\" android:value=\"true\" /\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n\n    \u003c!-- For iOS --\u003e\n    \u003cplatform name=\"ios\"\u003e\n        ...\n        \u003cconfig-file parent=\"WEGLogLevel\" target=\"*-Info.plist\"\u003e\n            \u003cstring\u003eVERBOSE\u003c/string\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n\n\u003c/widget\u003e\n```\n\n**Note:** Supported values for 'WEGLogLevel': 'VERBOSE', 'DEFAULT'.\n\n\n### 2. Location Tracking\n\nAdd the following tags in your `config.xml` file. \n\n```xml\n\u003cwidget ... \u003e\n    ...\n    \u003c!-- For Android --\u003e\n    \u003cplatform name=\"android\"\u003e\n        \u003cconfig-file parent=\"/manifest/application\" target=\"AndroidManifest.xml\"\u003e\n            ...\n            \u003cmeta-data android:name=\"com.webengage.sdk.android.location_tracking\" android:value=\"true\" /\u003e\n        \u003c/config-file\u003e\n        \u003cconfig-file parent=\"/manifest\" target=\"AndroidManifest.xml\"\u003e\n            ...\n            \u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n\n    \u003c!-- For iOS --\u003e\n    \u003cplatform name=\"ios\"\u003e\n        ...\n        \u003cconfig-file parent=\"UIBackgroundModes\" target=\"*Info.plist\"\u003e\n            \u003carray\u003e\n                \u003cstring\u003elocation\u003c/string\u003e\n            \u003c/array\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n\n\u003c/widget\u003e\n```\n\n\n## Tracking Users\n\nYou can set user attributes as shown in below example.\n\n```javascript\n// User login\nwebengage.user.login(\"user-id\");\n\n// User logout\nwebengage.user.logout();\n\n// Set system user attributes\nwebengage.user.setAttribute(\"we_first_name\", \"John\");\nwebengage.user.setAttribute(\"we_last_name\", \"Doe\");\nwebengage.user.setAttribute(\"we_email\", \"john.doe@gmail.com\");\nwebengage.user.setAttribute(\"we_birth_date\", \"1986-08-19\");\nwebengage.user.setAttribute(\"we_phone\", \"+551155256325\");\nwebengage.user.setAttribute(\"we_gender\", \"male\");  // Supported values: 'male', 'female', 'other'\nwebengage.user.setAttribute(\"we_company\", \"Alphabet Inc.\");\nwebengage.user.setAttribute(\"we_hashed_email\", \"144e0424883546e07dcd727057fd3b62\");\nwebengage.user.setAttribute(\"we_hashed_phone\", \"e0ec043b3f9e198ec09041687e4d4e8d\");\n\n// Set custom user attributes\nwebengage.user.setAttribute(\"Category\", \"GOLD\");\nwebengage.user.setAttribute(\"Value Index\", 5.06);\nwebengage.user.setAttribute(\"Inactive\", false);\nwebengage.user.setAttribute(\"Registered On\", new Date(\"2015-11-09T10:01:11.000Z\"));\n```\n\n**Note:** WebEngage SDK only supports the following data-types: String, Number, Boolean and Date.\n\n\n## Tracking Events\n\nYou can track events as shown in the following example.\n\n```javascript\n// Simple event\nwebengage.track(\"Added to cart\");\n\n// Event with attributes\nwebengage.track(\"Purchased\", {\"product-id\": \"123\", \"product-name\": \"wrist-watch\", \"product-price\": 25.65});\n```\n\n**Note:** WebEngage SDK only supports the following data-types: String, Number, Boolean and Date.\n\n\n## Push Notifications\n\n### 1. Android Push Notification Integration\n\n#### FCM Integration\n\n**1. Add this plugin to your Cordova project.**\n\n```\ncordova plugin add https://github.com/WebEngage/cordova-plugin-android-fcm.git --fetch\n```\n\n**2. Add google-services.json file.**\n\nFollow the steps at [Android FCM Documentation](https://firebase.google.com/docs/android/setup) to get the google-services.json file from Firebase Cloud.\n\nSave google-services.json file in the root of your project directory.\n\n**3. Update FCM token on app launch.**\n\nSend FCM token to WebEngage SDK in your `wwww/js/index.js` file.\n\n```javascript\nvar app = {\n    ...\n    onDeviceReady: function() {\n        ...\n\n        androidfcm.updateToken();\n    }\n}\n```\n\nDone. Run and test push notifications from WebEngage dashboard on your Android app.\n\n#### GCM Integration (Deprecated)\n\nAdd the following in your `config.xml` file, under android platform tag.\n\n```xml\n\u003cwidget ... xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n    ...\n    \u003cplatform name=\"android\"\u003e\n        \u003cconfig-file parent=\"/manifest/application\" target=\"AndroidManifest.xml\"\u003e\n            ...\n            \u003cmeta-data \n                android:name=\"com.webengage.sdk.android.project_number\" android:value=\"$12345678910\" /\u003e\n\n            \u003cmeta-data \n                android:name=\"com.webengage.sdk.android.auto_gcm_registration\" \n                android:value=\"true\" /\u003e\n\n            \u003creceiver \n                android:name=\"com.webengage.sdk.android.WebEngagePushReceiver\" android:permission=\"com.google.android.c2dm.permission.SEND\"\u003e\n                \u003cintent-filter\u003e\n                    \u003caction android:name=\"com.google.android.c2dm.intent.RECEIVE\" /\u003e\n                    \u003ccategory android:name=\"${applicationId}\" /\u003e\n                \u003c/intent-filter\u003e\n            \u003c/receiver\u003e\n\n            \u003c!-- Optional --\u003e\n            \u003c!-- Add only if the provided image exists --\u003e\n            \u003cmeta-data\n                android:name=\"com.webengage.sdk.android.small_icon\"\n                android:resource=\"@drawable/small_icon\" /\u003e\n\n            \u003c!-- Optional --\u003e\n            \u003c!-- Add only if the provided image exists --\u003e\n            \u003cmeta-data\n                android:name=\"com.webengage.sdk.android.large_icon\"\n                android:resource=\"@drawable/large_icon\" /\u003e\n\n            \u003c!-- Optional --\u003e\n            \u003cmeta-data\n                android:name=\"com.webengage.sdk.android.accent_color\"\n                android:value=\"#FF0000\" /\u003e\n        \u003c/config-file\u003e\n        \u003cconfig-file parent=\"/manifest\" target=\"AndroidManifest.xml\"\u003e\n            ...\n            \u003cuses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\" /\u003e\n            \u003cuses-permission android:name=\"${applicationId}.permission.C2D_MESSAGE\" /\u003e\n            \u003cpermission android:name=\"${applicationId}.permission.C2D_MESSAGE\" android:protectionLevel=\"signature\" /\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n    ...\n\u003c/widget\u003e\n```\n\n**Note:** Replace the value of android.project_number with your GCM/FCM Project Number (Sender ID).\n\n#### GCM to FCM Migration\n\n1. Follow the [FCM Integration steps](https://github.com/WebEngage/cordova-plugin#fcm-integration).\n\n2. Remove the following from your `config.xml` file, under android platform tag.\n\n```xml\n\u003cwidget ... xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n    ...\n    \u003cplatform name=\"android\"\u003e\n        \u003cconfig-file parent=\"/manifest/application\" target=\"AndroidManifest.xml\"\u003e\n            ...\n\n            \u003c!-- Remove these meta-data and receiver tags --\u003e\n            \u003c!--\n            \u003cmeta-data \n                android:name=\"com.webengage.sdk.android.project_number\" android:value=\"$12345678910\" /\u003e\n\n            \u003cmeta-data \n                android:name=\"com.webengage.sdk.android.auto_gcm_registration\" \n                android:value=\"true\" /\u003e\n\n            \u003creceiver \n                android:name=\"com.webengage.sdk.android.WebEngagePushReceiver\" android:permission=\"com.google.android.c2dm.permission.SEND\"\u003e\n                \u003cintent-filter\u003e\n                    \u003caction android:name=\"com.google.android.c2dm.intent.RECEIVE\" /\u003e\n                    \u003ccategory android:name=\"${applicationId}\" /\u003e\n                \u003c/intent-filter\u003e\n            \u003c/receiver\u003e\n            --\u003e\n        \u003c/config-file\u003e\n        \u003cconfig-file parent=\"/manifest\" target=\"AndroidManifest.xml\"\u003e\n            ...\n            \u003c!-- Remove these permissions --\u003e\n            \u003c!--\n            \u003cuses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\" /\u003e\n            \u003cuses-permission android:name=\"${applicationId}.permission.C2D_MESSAGE\" /\u003e\n            \u003cpermission android:name=\"${applicationId}.permission.C2D_MESSAGE\" android:protectionLevel=\"signature\" /\u003e\n            --\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n    ...\n\u003c/widget\u003e\n```\n\n### 2. iOS Push Notification Integration\n\nEnable 'Push Notifications' under capabilities tab in your XCode and then add 'WEGApnsAutoRegister' to info.plist with value true in `config.xml` file as shown below.\n\n```xml\n\u003cwidget ...\u003e\n    ...\n    \u003cplatform name=\"ios\"\u003e\n        ...\n        \u003cconfig-file parent=\"WEGApnsAutoRegister\" target=\"*-Info.plist\"\u003e\n            \u003ctrue /\u003e\n        \u003c/config-file\u003e\n    \u003c/platform\u003e\n\u003c/widget\u003e\n```\n\n### 3. Push Notification Callbacks\n\n```javascript\nwebengage.push.onClick(function(deeplink, customData) {\n    console.log(\"Push notification clicked\");\n    ...\n});\n```\n\n\n## In-App Notifications\n\nNo additional changes are required to show in-app notifications.\n\n### In-App Notification Callbacks\n\n```javascript\nwebengage.notification.onShown(function(inAppData) {\n    console.log(\"In-app notification shown\");\n    ...\n});\n\nwebengage.notification.onClick(function(inAppData, actionId) {\n    console.log(\"In-app notification clicked\");\n    ...\n});\n\nwebengage.notification.onDismiss(function(inAppData) {\n    console.log(\"In-app notification dismissed\");\n    ...\n});\n```\n\n\n## Troubleshooting\n\n### 1. Manifest merger failed\n\n```\nError: Element meta-data#com.webengage.sdk.android... at AndroidManifest.xml:... duplicated with element declared at AndroidManifest.xml:...\n...\nError:\n\tValidation failed, exiting\n```\n\nThis error is caused when there are duplicate meta-data tags in your AndroidManifest.xml file. To resolve this problem, simply run the command `cordova clean`.\n\n### 2. AAPT: Error: unbound prefix\n\n```\nA problem occurred configuring project ':app'.\n\u003e org.xml.sax.SAXParseException; systemId: file:/.../AndroidManifest.xml; lineNumber: ...; columnNumber: ...; The prefix \"android\" for attribute \"...\" associated with an element type \"manifest\" is not bound.\n```\n\nThis error is caused when AAPT cannot identify the prefix 'android' from your AndroidManifest.xml. To resolve this error, just add the android namespace attribute to the widget tag in your `config.xml` file as shown below.\n\n```xml\n\u003cwidget ... xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n    ...\n\u003c/widget\u003e\n```\n\n\n## Cordova Sample Project\n\nRefer our [Cordova Sample Project](https://github.com/WebEngage/cordova-sample) for sample usage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Fcordova-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebengage%2Fcordova-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Fcordova-plugin/lists"}