Once we have all the plugins installed, the next step is to actually use each of the plugins. We will need to open your main-page.js
file and add some code to use the plugin inside your application's main page.
We will start with this cool feature first. We want to make the device vibrate when a new message comes in. First, we just need to add the code to load the vibration component. Open the main-page.js
file. At the top of the file near the other required statements, you need to add a simple new require statement, var vibrate = require('nativescript-vibrate');
. Since all the messages already go through a central newMessage
function, let's add this code at the very bottom of this function:
if (msg.from !== 1) { vibrate.vibration(100); }
This code simply checks to see that the message doesn't come from us. After all, we don't really want to make the phone vibrate on our own messages. It then uses the vibrate
class that we required a...