how push notification works for phonegap build ?

  • 1
  • Praise
  • Updated 4 years ago
can some one provide me link of a good blog or video which contain step by step process of sending push notification using google cloud messaging ?

i have gone through tons of link but still do not found any thing useful so need help to understand the concept of GCM
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@vikash,

Reviewed Video Tutorials, but none about "push" - yet!

There are many good written tutorial on push online:
Google: Phonegap push gcm tutorial

This video is for CLI, not Build - Phonegap Plugin Push Tutorial. I watched it. At this time, it is correct. If you find one for PGB, let me know.

I recommend the tutorial by devgirl.org, even though it is out of date - done in 2013. (right now the website is down, so I can't tell what has changed.)

Here is better list to search by:
Top Bloggers for Cordova/Phonegap.

Best of Luck
Jesse
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
Good to see your reply!
while Browsing i found https://pushbots.com/ as very easy
followed https://www.youtube.com/watch?v=TdXXV... step by step
but its not working
Can you help me in fixing it?
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
I'm watching it right now. My connection is bad right now. It may be a while before I respond.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@vikash,
If you have the code in a zip file, can you put it some place public so I can look at all the code and your directory strucutre.

Jesse
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
i am creating a hello world app for that i will upload zip in minutes
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
Here is my zip hello world please look into it
http://farmtocustomer.com/www.zip
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@vikash,
okay. You have two mistakes.
1) change the directory structure so that what is in the www/ is the root.
This tutorial has the example. An HTML Boilerplate for Phonegap.

2) The new security protocol means you must use CSP in the header of your index.html _OR_ remove all CSS and Javascript from the index.html (in this case just move it to a file.)

Below is the code for the CSP.
This whitelist workshee should also help.
HOW TO apply the Cordova/Phonegap whitelist system

Best of Luck
Jesse

NOTE DOING THIS WILL MAKE YOUR APP INSECURE. IT IS UP TO YOU TO SECURE YOUR APP.
Add this to your config.xml

<plugin name="cordova-plugin-whitelist" source="npm" spec="1.1.0" />
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" /> <!-- Required for iOS9 -->

NOTE YOUR APP IS NOW INSECURE. IT IS UP TO YOU TO SECURE YOUR APP.
Add the followin to your index.html

<meta http-equiv="Content-Security-Policy"
content="default-src *;
style-src * 'self' 'unsafe-inline' 'unsafe-eval';
script-src * 'self' 'unsafe-inline' 'unsafe-eval';">
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
i dont get your point 1 as it is still in that structure only
2> * when * is used then why to white list any other thing
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
updated app as suggested but still not working
http://farmtocustomer.com/www.zip
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. You still have a directory /www in your zip, so index and config are not in the root. (I don't think this causes your app to "not work", though)

2. Your app runs into a javascript error on
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');

Do you see why?
And why do you have this coded, anyway?
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
i dont know i am using hello world app only hae modified index.js as suggested in api of pushbots i do not have any idea about this error
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
You have no html elements with a className as coded above. That means that both listeningElement and receivedElement are 'empty' and thus do not have a method called setAttribute()
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
http://farmtocustomer.com/123.zip
may be solved problem one look into it
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Nice, Vikash. Now you have everything twice. Two configs, two index.html....

Excuse me, but this may be way over your head. Are you sure you want to complete this project all by yourself?
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@petra v
i know i lack basics as i dont have any trainer or do not have attended any classes for that
i have coaded
goo.gl/nOUwg6
and

goo.gl/Nu3d6Q
by my self only
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Vikash,
I appreciate your efforts.
But....have another look at your package. It contains all errors I have shown you already three months ago in this thread:
http://community.phonegap.com/nitobi/...

- wrong directory structure
- old deprecated plugins
- blackberry stuff where it shouldn't be at all
- etc.

So, you may have no trainer and no classes, but it looks like you don't really learn much from the information you are receiving here, either.
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Petra V.
i have uploaded this one first but i dont know what is the problem in it
http://farmtocustomer.com/www.zip
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
That's the one you already showed about half an hour ago. I replied with two bullet points above, 31 minutes ago.
You should correct that, first. Then correct the config mistakes (old plugins, etc.).
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
corrected both one http://farmtocustomer.com/www.zip
still not working
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse @Petra V.
still not working
http://farmtocustomer.com/www.zip
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@viskash,
Not correct.

For *Phonegap Build*, `index.html` and `config.xml` both sit in the root directory and there is no `www/` directory. No other items are required, and infact you want to remove anything not list in `index.html` before uploading to *build.phonegap.com*.

Jesse
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse either you are getting wrong zip or i don't know the issue index.html and config.xml both are in root only
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@vikash,
It is your file. I have no idea what the issue is. Perhaps your server is caching the file - try changing the file name.

FWIW: here is a tutorial
An HTML Boilerplate for Phonegap
The files are on github and will load directly on to build.phonegap.com

Jesse
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
http://farmtocustomer.com/img.zip
Please check if something is worng in it ?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
In this zip, both config and index are indeed in the root.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
Too tired. All yours.
Jesse
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I have lost track of this thread.
The main question from the OP was, I believe:

... process of sending push notification using google cloud messaging ?
... so need help to understand the concept of GCM


Not sure how we arrived at looking at the zip file. OP wants information about sending notifications and the concept behind GCM.

So, I would suggest working your way through
https://developers.google.com/cloud-m...
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
Thanks Petra.

@Vikash
Let us know, if you get the build working.
Jesse
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
nothing is working infect it is not detecting device
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
I'm checking it now.
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
it is not working
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Vikash,
the app builds correctly.
If you are having an issue with the push, start a new thread and please say what the problem is IN THE NEW THREAD.

Jesse
Photo of vikash mishra

vikash mishra

  • 78 Posts
  • 0 Reply Likes
@Jesse
App has build successfully but push is not working
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
START A NEW THREAD.