New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification not showing..... #101

Closed
Chitranjanbariya opened this Issue Sep 4, 2015 · 12 comments

Comments

Projects
None yet
5 participants
@Chitranjanbariya
  1. I have created phoneGap application and add plugin (v. 1.2.0) in config.xml.
  2. Added JavaScript code in index.js on " onDeviceReady: function() " .
  3. Added GCM project number as "senderID" : "xxxxxxxxxx5462",
  4. Build with PGB and run application.
  5. GCM send a resgisrationID. (get successfully.)

But after this nothing happen..push.on('notification', function(data) not called.
Now Question is How can i send notification to application ?
so i can see notification on notification status bar in Android.

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 4, 2015

Member

@Chitranjanbariya well you'll only get a notification when you send one via GCM. There is a sample ruby file in example/server called pushGCM.rb and you can use that to send a test push.

You will only get notifications in the status bar when the app isn't running or is in the background.

Member

macdonst commented Sep 4, 2015

@Chitranjanbariya well you'll only get a notification when you send one via GCM. There is a sample ruby file in example/server called pushGCM.rb and you can use that to send a test push.

You will only get notifications in the status bar when the app isn't running or is in the background.

@Chitranjanbariya

This comment has been minimized.

Show comment
Hide comment
@Chitranjanbariya

Chitranjanbariya Sep 4, 2015

I have done it....
Thank you for reply..

I have done it....
Thank you for reply..

@slorber

This comment has been minimized.

Show comment
Hide comment
@slorber

slorber Sep 4, 2015

Contributor

@macdonst I have a similar problem.

Actually I have been able to receive the push notifications through the JS, only when the app is in foreground.
When the app is in background or closed, nothing happens.

I'm running the following CURL command

curl --header "Authorization: key=myKey" \
     --header Content-Type:"application/json" \
     https://gcm-http.googleapis.com/gcm/send \
     -d '{
    "to": "myRegistrationId",
    "priority":"high",
    "notification": {
        "title": "Stample title notif",
        "body": "Stample title notif",
        "text": "Stample text notif"
     },
}'

GCM answer "success: 1".

logcat shows:

I/GCM     (  929): GCM message co.stample 0:1441375473256746%fb71dcfaf9fd7ecd
V/GCMBroadcastReceiver(12833): onReceive: com.google.android.c2dm.intent.RECEIVE
V/GCMBroadcastReceiver(12833): GCM IntentService class: com.adobe.phonegap.push.GCMIntentService
V/GCMBaseIntentService(12833): Acquiring wakelock
V/GCMBaseIntentService(12833): Intent service name: GCMIntentService-GCMIntentService-5
D/PushPlugin_GCMIntentService(12833): onMessage - context: android.app.Application@41efd910
V/GCMBaseIntentService(12833): Releasing wakelock
D/ConnectivityService(  566): handleInetConditionHoldEnd: net=1, condition=100, published condition=100

So my phone received the push notification, but did not show anything in the notification bar.

It only works when the app is in foreground: this time the JS callback is fired.

Edit: this seems related to #93

Contributor

slorber commented Sep 4, 2015

@macdonst I have a similar problem.

Actually I have been able to receive the push notifications through the JS, only when the app is in foreground.
When the app is in background or closed, nothing happens.

I'm running the following CURL command

curl --header "Authorization: key=myKey" \
     --header Content-Type:"application/json" \
     https://gcm-http.googleapis.com/gcm/send \
     -d '{
    "to": "myRegistrationId",
    "priority":"high",
    "notification": {
        "title": "Stample title notif",
        "body": "Stample title notif",
        "text": "Stample text notif"
     },
}'

GCM answer "success: 1".

logcat shows:

I/GCM     (  929): GCM message co.stample 0:1441375473256746%fb71dcfaf9fd7ecd
V/GCMBroadcastReceiver(12833): onReceive: com.google.android.c2dm.intent.RECEIVE
V/GCMBroadcastReceiver(12833): GCM IntentService class: com.adobe.phonegap.push.GCMIntentService
V/GCMBaseIntentService(12833): Acquiring wakelock
V/GCMBaseIntentService(12833): Intent service name: GCMIntentService-GCMIntentService-5
D/PushPlugin_GCMIntentService(12833): onMessage - context: android.app.Application@41efd910
V/GCMBaseIntentService(12833): Releasing wakelock
D/ConnectivityService(  566): handleInetConditionHoldEnd: net=1, condition=100, published condition=100

So my phone received the push notification, but did not show anything in the notification bar.

It only works when the app is in foreground: this time the JS callback is fired.

Edit: this seems related to #93

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 7, 2015

Member

@slorber what version of the plugin are you using? Sending the push via the "notification" method should work in 1.2.1+. I'm on vacation this weekend (long weekend in North America) so I may not get a chance to test until next week.

Member

macdonst commented Sep 7, 2015

@slorber what version of the plugin are you using? Sending the push via the "notification" method should work in 1.2.1+. I'm on vacation this weekend (long weekend in North America) so I may not get a chance to test until next week.

@macdonst macdonst added retest bug and removed retest labels Sep 7, 2015

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 7, 2015

Member

@slorber I kinda lied because this was really bugging me I did pull out my laptop to do some testing and verified the problem and saw that you had and elegant fix for it so I merged it.

Member

macdonst commented Sep 7, 2015

@slorber I kinda lied because this was really bugging me I did pull out my laptop to do some testing and verified the problem and saw that you had and elegant fix for it so I merged it.

@macdonst macdonst closed this Sep 7, 2015

@slorber

This comment has been minimized.

Show comment
Hide comment
@slorber

slorber Sep 7, 2015

Contributor

thanks :)

tell me when you decide to release this fix please.

However @Chitranjanbariya you will have to test to ensure that this solves your problem (it may be a different problem...)

You can do so by using my forked branch:

<plugin name="phonegap-plugin-push"  spec="https://github.com/slorber/phonegap-plugin-push.git#master" />
Contributor

slorber commented Sep 7, 2015

thanks :)

tell me when you decide to release this fix please.

However @Chitranjanbariya you will have to test to ensure that this solves your problem (it may be a different problem...)

You can do so by using my forked branch:

<plugin name="phonegap-plugin-push"  spec="https://github.com/slorber/phonegap-plugin-push.git#master" />
@xavianaxw

This comment has been minimized.

Show comment
Hide comment
@xavianaxw

xavianaxw Sep 28, 2015

@slorber Have you been able to receive push notification when the app is closed since then? I'm unable to receive push notifications when my app is closed but it's fine when it's running on the background.

@slorber Have you been able to receive push notification when the app is closed since then? I'm unable to receive push notifications when my app is closed but it's fine when it's running on the background.

@slorber

This comment has been minimized.

Show comment
Hide comment
@slorber

slorber Oct 7, 2015

Contributor

yes it works for me @xavianaxw (try with my curl example, I remember I had troubles when the payload did not have title or body I think)

Contributor

slorber commented Oct 7, 2015

yes it works for me @xavianaxw (try with my curl example, I remember I had troubles when the payload did not have title or body I think)

@boyfunky

This comment has been minimized.

Show comment
Hide comment
@boyfunky

boyfunky Feb 25, 2016

i am unable to receive push notification when the app is in background or even when the app is closed. Were you guys able to do it? @xavianaxw @slorber?

i am unable to receive push notification when the app is in background or even when the app is closed. Were you guys able to do it? @xavianaxw @slorber?

@slorber

This comment has been minimized.

Show comment
Hide comment
@slorber

slorber Feb 25, 2016

Contributor

yes it worked for me

Contributor

slorber commented Feb 25, 2016

yes it worked for me

@boyfunky

This comment has been minimized.

Show comment
Hide comment
@boyfunky

boyfunky Feb 25, 2016

how did you get it to work @slorber? can share code?

how did you get it to work @slorber? can share code?

@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot Jun 5, 2018

This thread has been automatically locked.

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.