[Plugins] We've added push notifications to Build.

  • 1
  • Announcement
  • Updated 5 years ago
Here is some more information :)

https://build.phonegap.com/blog/intro...

If you have any issues with it let us know and we'll be happy to help!

Hardeep Shoker
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes

Posted 8 years ago

  • 1
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
ok. the problem should be resolved. please build again and give it a try.
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
glad it works, and thanks for your feedback.
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
I'm here again... My app is fine working both in android and ios using genericpush now, but I have a little question.

Actually in my app under android if the user exit the app (using back button or using other way) the push notification is still working (I make a litle change in the example code), but in this situation when the user touch the notification the app is not opened... if the app is in the background using home button the app opens after touch the "notification".

My question is, Is there any way to open the app from the push notification touching it even if the user exit the app, in a similar way that works under ios.. where even if the app is closed (not in background) you can open the app touching the notification.

Thanks in advance, I know that is not very important... and probably imposible but I wabt to confirm this.
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
Unfortunately, this is how it works on android. If the app completely exits, there is no activity to receive the notification. You might want to trap on the backbutton event and force the user to exit via the home button. Realistically though most users will use the home button to exit an app which puts it in the background.
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
Thanks for the answerd... :)

I thought so, there's no problem... the important is that the user recibe the notification in any case, and as you say usually we use home botton for exit :)

Thanks for all :)
Photo of Koen schmeets

Koen schmeets

  • 1 Post
  • 0 Reply Likes
I still get this error "*appname* has closed" when sending pushes when the app is running in the background.

I load the GenericPush plugin like this:

gap:plugin name="GenericPush"

So it should load the latest version.

Does anyone know what's up?
Photo of maurizio

maurizio

  • 60 Posts
  • 1 Reply Like
sorry maybe I do not understand ..
pushplugin can not activate the app or part of it?
I need to activate a function of the app that geolocate the device and send coordinates to my servers,
if the app is already active it work,
but if the app is turned off, only one message appears ... is that correct?
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
When the app is in the background, incoming notifications go to the status tray. Touching that notification should activate your app. Your app can then process the notification payload as it sees fit.
Photo of maurizio

maurizio

  • 60 Posts
  • 1 Reply Like
Ok , so if anyone touches the notification I can not activate the app?
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
If you touch the notification it WILL activate your app, as long as it has not been force quit by the back button or another process.

UPDATE: Pressing the notification from the tray should now activate your app, even if it was exited via the Back button.
Photo of Kanika

Kanika

  • 1 Post
  • 0 Reply Likes
Hi,

I too see the error "Unfortunately, has stopped" when I look at a background push notification, but only when the application isn't running (closed via back button). The app shows up fine when it's backgrounded (via home button).

I followed Holly Schinsky's tutorial to setup push notifications for Android.

I just used the sample project there with modified index.js (with my personal info and GCM id) and config.xml (GenericPush as the plugin name instead of PushPlugin) files. And uploaded the www zip folder to phone gap build service. Then I setup a push server as in the tutorial.

Device - Samsung Galaxy SIII, Android 4.1.2

Is this the problem that Oscar and Sean faced? Is it fixed? Is there really no way to exit an app and then activate it using a notification?

Thanks.
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
I have a little problem (only under android )... actually this plugin works fine in my app, but now I want to send from my server an aditional key and not only the message, works fine but the value of the key is the same for minutes even if a new push notification is sent using other value.

Searching on the net I found a posible reason "pending intent is not being updated"... The problem described is exactly what is happening in my app... and someone offer this solution "update pendding intent..."

http://stackoverflow.com/questions/13...

Any idea about this issue...
Photo of srknc

srknc

  • 8 Posts
  • 0 Reply Likes
Hi,
I'm using push notification plugin, it's working like yours and it's also working when i touch the back button. But when i close the application from task manager, notification doesn't seen at task bar, means it's not working. Is it normal? Is this a known problem or i made a mistake in my app.
Thanks.
Photo of gkatz

gkatz

  • 186 Posts
  • 5 Reply Likes
Hi all;
first of all, thanks for PGB, love it. used it to deploy IOS and android app a year ago.
now a year has past and I am working on the next gen of my app. mainly trying to add push notifications. I was happy to see that I came just in time as the GenericPush plugin is now integrated with PGB.

however, reading this post and the docs I still don't understand the exact capabilities of this plugin. for example, I can't seem to understand if notifications will be sent to the device and shown on the device even if the my app if not opened/running at that specific moment. this is crucial to me.
also, pushwoosh seems to be on the way to PGB, are these plugins the same in functionality? why would I choose one over the other?
thanks in advance and thanks for your time and effort
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
Yes the pluging works even if the app is in the background or closed
Photo of srknc

srknc

  • 8 Posts
  • 0 Reply Likes
Hi Oscar,
My app's notification (android) doesn't work when i closed it from task manager.
Photo of mp

mp

  • 69 Posts
  • 1 Reply Like
Hi Oscar

I am using phonegap build(latest version), and in my case, it doesnt open the app if the app is in exited mode..(not running in background-ANDROID)
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
In my app if the user presa the home or back Burton to exit the plugin work ... In any other situation like kill the app ir reboot the device the user must open the app again only for the first time.... The only problem that I have is to recive data when the app was stoped fby Android
Photo of Maurizio Sordo

Maurizio Sordo

  • 15 Posts
  • 1 Reply Like
So, it is possibile to know the position of the device if app is closed ?
Like pushwoosh...
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
By "position", are you referring to GPS coordinates? If so, then no. THe GenericPush plugin does not provide GPS location.
Photo of maurizio

maurizio

  • 60 Posts
  • 1 Reply Like
Yes, GPS coordinates. I look forward to PushWoosh Plugin ... thanks
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
srknc:. Please verify it works as expected if you exit the app either from the Home button or the Back button.

I'll look into whether its possible to restart the app when exited from the Task Manager.
Photo of Maurizio Sordo

Maurizio Sordo

  • 15 Posts
  • 1 Reply Like
Hi Oscar,
I can confirm a similar issue.
I had already post about this problem, but no one gave me a answer.
In my case the app continuosly to get the GPS position and send it to my servers.
When the app exited with home button or because the phone receive a call , after some minute stop to work.
Only now I have understood that this issue is began when I have included the GenericPushPlugin in the app.
Now, I try to remove pushplugin.
Photo of Maurizio Sordo

Maurizio Sordo

  • 15 Posts
  • 1 Reply Like
No, without pushplugin the problem persist.
After a few minute the app stop to work.
If I try to reopen the App before she stop to work,
I see the isplash screen and the app is in the initial state,
but when i close the app with "app.exit"
the app return in the state where was when I had exited with the home button.
So, I suppose that android launch 2 app in the same time
I do not think is a problem with Js code,
maybe PhoneGap have problem with process managment on Android ?

PS
On Blackberry and iOS all works fine.a
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
What version of phoneGap are you guys targeting?
Photo of Maurizio Sordo

Maurizio Sordo

  • 15 Posts
  • 1 Reply Like
I have this problem with 2.3 and 2.5, but I remember that one once this was fine.
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
My issue happens with all the versions i have tested
Photo of gkatz

gkatz

  • 186 Posts
  • 5 Reply Likes
interesting.
Bob, please do let us know if such a use case (task manager exit) can be supported by the gen push plugin and if you intend to incorporate it.
thanks.
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
Exiting the app from the Task Manager exits the broadcast receiver and no notifications are then received. This is working as designed. However, If you exit via the Home button OR the Back button, you will still receive notifications.

We have no plans to support the use case of leaving services running after a forced exit of an application via the Task Manager.
Photo of mp

mp

  • 69 Posts
  • 1 Reply Like
Hello Phonegap Team,

I have been using PGB since a year and I am gartefull to PGB.
Since last month I am trying to add push notifications, genericpush plugin seems cool for my use, but I have some crucial issues listed below:

- As for everybody else,it doesnt open the android app if the app is not running in the background.

-The more important issue is, i can not retrieve other key-value pairs from my data sent from server below:

$fields = array(
'registration_ids' => $registrationIdsArray,
'data' => $messageData,
);
where i am encoding the $field to JSON and send it to GCM. the $messageData is as an array(cakephp).

array('message' => $message, 'matchId' => $eventData['match_id'], 'contentTitle' => $contentTitle, "contentText" => $contentText)

I am using Holly Schinky's tutorial and sample app (http://devgirl.org/2013/01/24/push-no...)

The problem is that I can retrieve e.message but not other key-value pais like e.matchId.

-One more thing is the title of notification.In android it is always teh name of the app as title(big fonts) and the message data as small text.Is it possible to eliminate the app name as title so that more text from message data can be accomodated.?

-And the even bigger issue is I dont know where to write the code for doing particular activity on push notification for appe.I ahve tried writting it in onNotificationAPN finction (just some alerts to test) but it doesnt work.

I hope my question is clear to understand or I can elaborate more if needed.
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
Can you get any data sent in a notification ejem the app is in background but closed by Android after a time of nactivity? In my case I can't.

I have the same question as you write in last place
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
In any case, even if there's a low memory issue, it's something that I can control in my app... is there a way (without reading the content recieved by push notification) to open a specific page acording the data sent into the push notification... ???
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
I'm probably misunderstanding your question. You seem to be asking if you can navigate to a page specified in the notification without actually reading that notification. The answer then would be no.

Please clarify what you are asking.
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
Yes that was the question, get an alternative way to open an specific page ... Thanks for the answer.
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
Understood. You are looking for similar functionality to iOS's custom URL scheme. Several customers have asked for a plugin to accomplish that, but we have not worked on anything like that. There may be Cordova plugins that do that, but they would not be currently available to PhoneGap Build users.
Photo of Oscar Abilleira Muñiz

Oscar Abilleira Muñiz

  • 157 Posts
  • 5 Reply Likes
After upgrading my app to 2.9.0 version under build service I can open an specific page (reading the data from push notification), even after some time of inactivity.. or exit the app ;)
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
Hi mp,

For android, notifications are processed if the app is not in the background, but only if the app was exited via the back button.

GenericPush will not process notifications if the app was force-quit via the settings app or the Activity Manager. This is by design.

The user who force-quits an app has the expectation that the app and all of its processes will relinquish any resources they may be using. On android, the notification service is owned by the individual app, unlike on iOS where it is a system service. When the app is force-quit, that process is exited with it.

With respect to custom content, the event delivered to the app contains a payload node. This is where you should be able to access your custom data. In your case, I believe you would use something like e.payload.matchId. Please see the example posted @ https://github.com/phonegap-build/Pus....

The text in the notification tray uses a fixed layout, so eliminating the title text would not add room for additional message text. The tray text is intended only to give you the gist of the message allowing you to decide whether to launch the app for further processing. While it is possible to change to a custom layout for the Tray message, doing so is currently beyond the scope of the plugin.

onNotificationAPN() is the correct place to process incoming notifications for Android. Please refer back to the example linked above. You will see that the example posts the incoming notification text into the body of the webview. You could modify that to display alerts, parse the data or do whatever, based on the incoming payload.
Photo of mp

mp

  • 69 Posts
  • 1 Reply Like
Thnx bob.

by the way onNotificationAPN() is for iOS where I expect to put the code for "what to do on clicking notification", but I cant.

For android, it is onNotificationGCM()(works fine..!!! :) ), where I place my code in three different cases
{e.foreground}elseif { coldstart }else{launch from bakground}.

Now everything clear about android, just expect little more favour for iOS( running the code on launching the app from notification-onNotificationAPN())
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
Right you are.

Are you having problems receiving or processing iOS notifications?
Photo of Xxp2

Xxp2

  • 12 Posts
  • 0 Reply Likes
PushPlugin needs to be updated so it works wtih PhoneGap 2.7's way of writing Plugins. It was working fantastically on 2.6 but since upgrading, we can't even build anymore :(

Can you please update the repo https://github.com/phonegap-build/Pus...
Photo of mp

mp

  • 69 Posts
  • 1 Reply Like
i am having problem processing iOS notifications, I receive them quite well, but when I click them, I want them to open specific page .
Photo of mp

mp

  • 69 Posts
  • 1 Reply Like
any update on this...??
Photo of Xxp2

Xxp2

  • 12 Posts
  • 0 Reply Likes
PushPlugin needs to be updated so it works wtih PhoneGap 2.7's way of writing Plugins. It was working fantastically on 2.6 but since upgrading, we can't even build anymore :(
Photo of Noah Borg

Noah Borg

  • 2 Posts
  • 0 Reply Likes
That's why I was also waiting for Pushwoosh plugin to be approved. They have already supported 2.7, ahead of everyone else, including the PhoneGap team itself.
Photo of Claes Gustavsson

Claes Gustavsson

  • 69 Posts
  • 1 Reply Like
I ́m also waiting for PushWoosh to work with the build service, they said 3 months ago that it would take a couple off weeks to include the plugin...
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
We will be updating all of our plugins when we add support to Build for 2.7. We expect this to happen within the next couple of weeks.
Photo of mp

mp

  • 69 Posts
  • 1 Reply Like
Hi phonegap,

I am almost re-posting this question(but in somewhat clearer way to understand).

What should i do to achieve foreground and cold start functionalities in iOS?I mean in android I use "e.foreground" and "e.coldstart". Is there something similar for iOS too....?
Photo of Guido Smeets

Guido Smeets

  • 3 Posts
  • 0 Reply Likes
I have nearly finished a patch that solves these issues, and also fixes 2.7 compat. Should I do a pull request? If so, should I do that on Bob's branch, or on the Phonegap-build branch?
Photo of Guido Smeets

Guido Smeets

  • 3 Posts
  • 0 Reply Likes
I've finished the update to 2.7, which also includes some bugfixes (fixed it crashing when you navigated out of the app via the back button.) I've also cleaned up a lot of stuff, which improves readability of the code hopefully.

For people that are doing local builds and want this now, you can grab a copy at my company's branch: https://github.com/NetMatch/PushPlugin
Photo of Xxp2

Xxp2

  • 12 Posts
  • 0 Reply Likes
Thank you Guido, this is working for us on iOS and Android. Really appreciate it.

Just a quick change had to be made:
Moving libs/gcm.jar to src/android/libs/gcm.jar so that it installed correctly with Plugman.
Photo of Guido Smeets

Guido Smeets

  • 3 Posts
  • 0 Reply Likes
You're welcome. I wasn't aware of that Plugman requirement. I'll update my branch to reflecct that change, it should be merged in along with the rest of my pull request.
Photo of Brian Hann

Brian Hann

  • 6 Posts
  • 0 Reply Likes
I absolutely 100% cannot get this plugin to work with Phonegap Build. I have tried using both a plugin name of "PushPlugin" and "GenericPush"with both version 2.7.0 and 2.5.0.

All attempts with the example app here: https://github.com/phonegap-build/Pus... result in a "Class not found" error.

Any suggestions?
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
ok let me context-switch to android and see what I find
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
Ok It builds and runs for me on Android with the above mentioned change. I re-checked your app on build and see that the latest Android build failed. Are we still talking about the same "Class not found" problem?

The new build error looks like an incorrect password entry for the signing key. Try building the Android app without a signing key (ok on android) and with the GenericPush change, and let me know what it does.
Photo of Brian Hann

Brian Hann

  • 6 Posts
  • 0 Reply Likes
I rebuilt with those changes and am getting the same error on my phone, however I just checked it in an emulator and it's working there. Perhaps it's something to do with having the broken version originally installed and then hydration updates after that? I will try uninstalling and reinstalling but unfortunately I'll have to wait till later this evening.

Thanks for your help, Bob, and I'll let you know how it goes!
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
np. Also try rebuilding without hydration on to see if that makes a difference
Photo of Brian Hann

Brian Hann

  • 6 Posts
  • 0 Reply Likes
@Bob uninstalling and reinstalling fixed it! Thank you very much for debugging this with me.
Photo of Maurizio Sordo

Maurizio Sordo

  • 15 Posts
  • 1 Reply Like
"Class not found" result from server or from app?
Photo of Brian Hann

Brian Hann

  • 6 Posts
  • 0 Reply Likes
@Maurizio: it's being passed to the pushNotificaiton.register error callback here: https://github.com/phonegap-build/Pus...