Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Notification not showing..... #101

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

Notification not showing..... #101

Chitranjanbariya opened this issue Sep 4, 2015 · 12 comments
Labels

Comments

@Chitranjanbariya
Copy link

  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
Copy link
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
Copy link
Author

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

@slorber
Copy link
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
Copy link
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
Copy link
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 as completed Sep 7, 2015
@slorber
Copy link
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
Copy link

@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
Copy link
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
Copy link

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
Copy link
Contributor

slorber commented Feb 25, 2016

yes it worked for me

@boyfunky
Copy link

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

@lock
Copy link

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.
Labels
Development

No branches or pull requests

5 participants