Rushikesh
Rushikesh

Reputation: 117

How to generate dynamic push notification in cordova-vuejs hybrid app?

I am using codova and vuejs for making hybrid app. I want to generate dynamic push notifications based on users data. How can we do that ?

Upvotes: 1

Views: 1451

Answers (1)

Nidhin Joseph
Nidhin Joseph

Reputation: 10237

If you are in search of a plugin that can help you with a push notification from the server, then OneSignal is one among the best.

Installation

cordova plugin add onesignal-cordova-plugin

Configuration

// Add to index.js or the first page that loads with your app.
// For Intel XDK and please add this to your app.js.

document.addEventListener('deviceready', function () {
  // Enable to debug issues.
  // window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});

  var notificationOpenedCallback = function(jsonData) {
    console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
  };

  window.plugins.OneSignal
    .startInit("YOUR_APPID")
    .handleNotificationOpened(notificationOpenedCallback)
    .endInit();
}, false);

Now, if you want something without the server, one that just works locally, the Cordova Local-Notification Plugin is the best option

Installation

cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git

Configuration

cordova.plugins.notification.local.schedule({
    title: 'My first notification',
    text: 'Thats pretty easy...',
    foreground: true
});

Upvotes: 1

Related Questions