cordova-base-push-android
v1.0.6
Published
Cordova BASE push Android
Downloads
3
Maintainers
Readme
cordova-base-push-android
This a Cordova plugin for BASE push notifications. It provides the functionality required to use FCM Push notifications from the BASE TSS System within a Cordova Android application.
Supported platform
- Android
Installation
Installling the plugin:
cordova plugin add cordova-base-push-android
Adding your google-service.json file to your project
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
Getting the device token
The following function return the device token in the success callback
cordova.plugins.baseTss.getToken(function (token) {
console.log('PUSH TOKEN : ', token);
},
function (error) {
console.log('PUSH ERROR : ', error);
});
Subscribe for Push notifications
Please provide the necessary parameters to the plugin. The registrationString should be a valid JSON containing using the following format :
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.
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);
Unsubscribe from Push notifications
You can unregister for push notifications using the following function.
cordova.plugins.baseTss.unregisterDevice(successCallback, failureCallback);
Customized icons
- 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:
<resource-file src="res/icon/android/base_push_logo/drawable-hdpi/base_push_logo.png" target="app/src/main/res/drawable-hdpi/base_push_logo.png" />
<resource-file src="res/icon/android/base_push_logo/drawable-mdpi/base_push_logo.png" target="app/src/main/res/drawable-mdpi/base_push_logo.png" />
<resource-file src="res/icon/android/base_push_logo/drawable-xhdpi/base_push_logo.png" target="app/src/main/res/drawable-xhdpi/base_push_logo.png" />
<resource-file src="res/icon/android/base_push_logo/drawable-xxhdpi/base_push_logo.png" target="app/src/main/res/drawable-xxhdpi/base_push_logo.png" />
<resource-file src="res/icon/android/base_push_logo/drawable-xxxhdpi/base_push_logo.png" target="app/src/main/res/drawable-xxxhdpi/base_push_logo.png" />
Customized sounds
- Adding this to your config.xml will copy the sound files to your android platform.
<resource-file src="notifications_sounds/alarm.ogg" target="app/src/main/res/raw/alarm.ogg" />
- From base send the name of your sound file (without extention) e.g: in this case send "alarm"
Author
This plugin was created by Mohamed ali Tlili so please don't hesitate to send an email to
Licence
Daimler AG Internal Source License Version 0.2, 24 January 2017 Preamble The goal of this license is to enable sharing of source code and other kinds of works within the Daimler corporation. It is intended to be used for all contributions for the benefit of projects within the whole of Daimler AG. Terms and Conditions Copyright (c) 2017 Daimler TSS, Architecture and Mobile Technologies. All rights reserved.
- Redistributions inside Daimler AG are permitted in source code and binary forms, with or without modification, provided that they retain the above copyright notice, this list of conditions and the following disclaimer
- Redistributions to outside Daimler AG are permitted in binary form under the copyright of Daimler. This includes commercial use.
- Redistributions to outside Daimler AG in source code form require the prior written permission of the contributing department and must retain the above copyright notice, this list of conditions and the following disclaimer. THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTING DEPARTMENT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTING DEPARTMENT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.