Cordova Plugin Overview¶
Download¶
There are three ways you can add cordova-plugin-tango to your Cordova project:
via config.xml
dependency¶
<plugin name="cordova-plugin-tango" spec="<specify-version>" />
from npmjs¶
Navigate to your project and run the following line:
cordova plugin add cordova-plugin-tango
from Git¶
Navigate to your project and run:
cordova plugin add https://github.com/tangotargeting/cordova-plugin-tango.git
Installation¶
Usage¶
Prepare the SDK¶
In order to use it correctly, Tango Targeting SDK should be initialized as soon as possible when your Cordova App launches. In your project's index.js add the following line at the top of your onDeviceReady
method.
window.TangoPlugin.initialize('your-tango-sdk-key');
This will register the device on TangoTargeting and prepare it for consuming campaigns.
Important
To find your Tango API KEY Go to Console and locate the card Tango SDK Key
then hover it and click the copy icon on the right.
Note
Explicitly initializing Tango is only needed for iOS. On Android the SDK auto-initializez, provided it can find the API Key in the manifest file. See Android Installation.
Trigger an Automated Campaign¶
Automated campaigns can be triggered using the following method call:
window.TangoPlugin.trigger('your-automated-campaign-trigger');
You can find the campaign trigger string by clicking on the campaign in your Tango Console.
Handle custom actions¶
Handling a custom action is as easy as extending TangoPlugin
with the following method:
window.TangoPlugin.onCustomAction = function(action){ // identify the action and do stuff };
Manage tags¶
You can add segments to a device to allow it to widen the pool of campaigns it can receive with the following method:
window.TangoPlugin.addSegments(["first-segment", "second-segment"]);
Troubleshooting¶
-
If you completed the integration but don't receive any campaign, make sure you use the the API Key (see above how to find your API Key) and NOT the Public API Key.
-
Sometimes, depending on the version of your Cordova Framework version or Cordova wrappers like Ionic or Phonegap, the configurations in config.xml may not be applied to the platforms/android/AndroidManifest.xml. To fix this you can use the cordova-custom-config plugin which will make sure the configurations will pe applied to their respective platforms.