Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse Ionic App auto push notification possibilities

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?

like image 466
jdfauw Avatar asked Oct 31 '22 11:10

jdfauw


1 Answers

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,

like image 119
Incpetor Avatar answered Nov 09 '22 02:11

Incpetor