Reputation: 303
I'm newbie in ionic2 framework. Please suggest suitable plugin or solution to develop push notification from server in ionic2 application.
Thanks, DSCanon
Upvotes: 2
Views: 892
Reputation: 918
Please use the ionic-cloud-angular released by the Ionic team for utilising their services like Auth, push, deploy etc., in Ionic 2 apps.
You can refer here for Push Notifications - http://tphangout.com/ionic-2-push-notifications/
It gives detailed and simple instructions on how to achieve this.
Hope this helped you. Thanks.
Upvotes: 0
Reputation: 44669
You can also use OneSignal which is completely free and then you can follow these steps to add it to your Ionic2
application.
After setting everything up like it's explained in that post, you would need to install the oneSignal cordova plugin
cordova plugin add onesignal-cordova-plugin
Then, add the following code to your app.ts so that it runs on startup:
document.addEventListener('deviceready', function () {
// Enable to debug issues.
// window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});
let appId = "CHANGE ME";
let googleProjectNumber = "CHANGE ME";
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
window.plugins.OneSignal.init(appId, {googleProjectNumber: googleProjectNumber}, notificationOpenedCallback);
// Show an alert box if a notification comes in when the user is in your app.
window.plugins.OneSignal.enableInAppAlertNotification(true);
}, false);
Note: substitute in your
appId from OneSignal
googleProjectNumber
Upvotes: 3
Reputation: 5720
You can use Push from Ionic2 Native import {Push} from 'ionic-native';
Here you can find more information about setting up your app.
Upvotes: 1