Cordova BASE push Android
npm install cordova-base-push-android
cordova plugin add cordova-base-push-android
`
$3
The google-services.json file is generally placed in the app/ directory (at the root of the Android Studio app module).
If you don't have a google-services.json file yet, please take a look at this link https://firebase.google.com/docs/android/setup
- IMPORTANT: If you don't provide the google-services.json file the app will fail to build. Usage
$3
The following function return the device token in the success callback
`javascript
cordova.plugins.baseTss.getToken(function (token) {
console.log('PUSH TOKEN : ', token);
},
function (error) {
console.log('PUSH ERROR : ', error);
});
`$3
Please provide the necessary parameters to the plugin.
The registrationString should be a valid JSON containing using the following format :
`javascript
var registrationJSON =
"[
{'category':'testCategory_1',
'topics':['testTopic_1','testTopic_2']
},
{'category':'testCategory_2',
'topics':['050']
}
]";
`Please note that the keywords 'category' and 'topics' are recognized by the plugin and that you should use them in your registration payload.
`javascript
var gcmSenderId = "XXXXXXX";
var baseUrl = "https://base.daimler-tss.com/base.push.server/";
var apiKey = "XXXXXXXXXXXXXXXX";
var registrationJSON = "[{'category':'testCategory_1','topics':['testTopic_1','testTopic_2']},{'category':'testCategory_2','topics':['050']}]"; cordova.plugins.baseTss.registerDevice(gcmSenderId, baseUrl, apiKey, registrationJSON, successCallback, failureCallback);
`$3
You can unregister for push notifications using the following function.
`javascript
cordova.plugins.baseTss.unregisterDevice(successCallback, failureCallback);
`
$3
- If you want to customize your app's icons please generate them with the following tool http://romannurik.github.io/AndroidAssetStudio/icons-notification.html
- IMPORTANT: please name your image files "base_push_logo"
- The website will generate a file called "base_push_logo" please copy it in the directory [PROJECT_NAME]/res/icon/android/
- The icons should be mentioned in your config.xml file to be copied in the project. Example:
`xml
`$3
- Adding this to your config.xml will copy the sound files to your android platform.
`xml
``