I'm makin this cordova/ionic project in which I'm using Parse for the backend. I want users to be able to send a message to other users. When doing so, a push notification should appear at the receiver's device.
This should work cross Android and iOS.
Would this be possible using only Ionic and Parse?
I am working on a similar project.
Below are some steps to get basic Idea
a. Register to Parse.com
b. For building with project with Ionic you'll need a JS plugin for accessing Parse Components. Use this GitHub Plugin
c. Copy paste the below code in ionicPlatformReady()
in app.js
// You'll get the appId and Clinet Key from Parse.com
parsePlugin.initialize(appId, clientKey, function() {
parsePlugin.subscribe('SampleChannel', function() {
parsePlugin.getInstallationId(function(id) {
/**
* Now you can construct an object and save it to your own services, or Parse, and corrilate users to parse installations
*
var install_data = {
installation_id: id,
channels: ['SampleChannel']
}
*
*/
}, function(e) {
alert('error');
});
}, function(e) {
alert('error');
});
}, function(e) {
alert('error');
});
d. From the Parse account dashboard, send a push notification for testing and you should be able to see it.
Note
It is very likely that you may get error saying Reference to parsePlugin not defined.
which means the cordova plugin is not getting loaded while execution.
I hope it helps. All the best.
Thanks,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With