-
Notifications
You must be signed in to change notification settings - Fork 992
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
OnResume from background, all my notification disappear but no Event Call Back #525
Comments
Your |
@samvrlewis But what happen when i click the App Icon to resume the App? I am still confused because in some of the comment like #423, the last comment by Gionni, he said in the latest version 2.4.0, the issue has been fixed? So i should be able to just click the App icon to resume to the app and by using onResume, i should be able to trigger a ECB? Because at the moment, when i resume the App by clicking the App icon, it clears my notification Tray, but there is no ECB. |
I have window.onNotificationGCM = function(e) {} then i call if (e.foreground) {} else{ if (e.coldstart){}else{} Not sure how am i supposed to call for ECB or if i am able to do so when i resume by clicking the App icon but not the notification. (Documentation didn't mention it for version 2.4.0) |
Sorry, misunderstood what you were asking. If you're developing for Android can you modify the plugin as Gionni does here: #423 (comment) ? |
@samvrlewis 2.) I also need this for IOS(Def) and Win Mobile(possibly). I am just wondering if you have any experience on it? And when you resume the App by clicking the App icon, and then putting the App back to the background, does that deletes your tray as well? I am ok with it, as long as it doesnt delete my tray if i put it in the background. (but i still need it to be cleared, if i click on the notification). |
It's hard to be sure but maybe 2.4.0 fixed it on iOS? I'm only using On Tue, 7 Apr 2015 15:59 clarklight [email protected] wrote:
|
@samvrlewis Ahh ok, no problem. But just wondering if that deletes your notification tray as well ?(when you put the App back to the background(if you resume the App by App Icon) but not clicking the notification)...... and 1 problem is i am using Phonegap Build at the moment, so the changes in Java and such i have to move all my other plugins and package them all again in CLI. |
For me if I have a notification then open the app through the app icon the notification remains. However, if I minimise the app again the notification disappears. Definitely not ideal behaviour! I am using Cordova instead of PhoneGap though. |
@samvrlewis yes, when you minimise it(the "Pause") action triggers the "clear" function. By the way, i was doing some research and found that a few people forked this version and made some changes, and made it into phonegap builds plugin. https://build.phonegap.com/plugins. (search for push, and remove window phone 8) |
Ah yep, just found that too. Removing |
@samvrlewis i just found that line in the pushplugin.Java as well but I am still trying to figure out what i gotta do, because i am using phonegap build.(not packaging it through CLI) And i am trying to find a way, if there are any of those phonegap build version has this notificationManager.cancelAll() line in. So i dont have to transfer every plugin i have into/thru CLI(as i will have to move all my files etc). 1 odd thing is no one is maintaining this project and continuing on the updates, as push notification is pretty important nowadays, and Phonegap has no official version. So without this, Phonegap has "No" push plugins really, which is weird(350k apps are using this plugin, but no one is maintaining it). I just realized, even if i remove that line, it might just a temporary fix for me, cos i have to do the same for IOS then Win.....and i have 0 experience in Objective c or swift. |
That line is line 134 of PushPlugin.java, I commented out lines 134 and 135. I agree that it is very weird that it's not maintained, would have thought it would've been a priority as well. The Android code even uses a depreciated API from Google. It might be worth asking on the PhoneGap support forums why this plugin isn't being maintained? BTW, this pull request might be useful for you as well but I haven't tested it: #279 |
@samvrlewis Thanks! by the way http://stackoverflow.com/questions/29204334/how-to-handle-push-notification-when-application-is-resumed I have actually opened a Thread on Phonegap Forum, about this onResume issue. No reply. Stupidest thing is, (the quickest way for me to achieve it, is by removing those 2 lines, submit the plugin and then i can use phonegap build to package it). But i gotta upgrade my account, i dont even know how to upgrade my account. Just wondering, if you tested taking that final NotificationManager notificationManager = (NotificationManager) cordova.getActivity().getSystemService(Context.NOTIFICATION_SERVICE); |
Yep I think that's similar to Gionni's solution that I linked to before? I think alerting PhoneGap that the plugin isn't being maintained at all might be more useful than telling them this specific issue. I'm not sure but it may be the intended behaviour that the notification isn't received until the notification icon is pressed -- posting about that issue might not get much interest. I did see that someone else posted on the support forums about this plugin not being maintained/pull requests not being accepted: http://community.phonegap.com/nitobi/topics/official-pushplugin-plugin-have-many-issues-and-pull-requests-must-to-fix-it-and-merge-it. It may be worth raising an issue in the PhoneGap build repo like this one phonegap/build#298 as suggested. I did test taking out those two lines. When the lines are removed it just stops the notification disappearing when the app is paused, it doesn't change the onResume behaviour. To get the onNotification event to fire when the app is resumed I think you'll have to use either that StackOverflow solution or Gionni's solution. |
Ahh ok, i was actually digging into the Java, i dont really have much experience in Java, just some experience in AS3. I was thinking if for the public void onResume set the PushPlugin.sendExtras(extras); in there, maybe it triggers the ECB passthru. But i am really bad in OOP so. i will keep this fix for now. And also raise the "alert" on Phonegap Forum. The problem with the stackoverflow fix, is that it turns it into a silent passthrough, i assume. The best behavior would be the one they have on Gmail/Gchat. When on resume the ECB is triggered. But for now. I will have to deal with it for Android, then figure something out for IOS. Do you have any experience in submitting plugins in phonegap? |
I just tested the StackOverflow solution; calling I don't have any experience in submitting plugins, sorry. Building the app myself with Cordova wasn't very hard though, I assume it's similar for PhoneGap. |
Ahh ok, thanks! I was thinking it has something with silent pass-thru. |
Yep, so the ecb fires for me if I:
The only slight problem is that if you have a notification, open the app through the app icon and then click the notification icon, the ecb will fire both times. If this isn't desired behaviour you could fix by cancelling the notifications when the cached extras are sent. Also, you'll still need the other fix I mentioned in #525 (comment) if you don't want notifications cancelled when the app is paused. I'd be very interested to hear what the behaviour is on iOS, let me know how you go with it. I have a feeling it may be totally different to Android and just work as we expected. I think this project was merged in from multiple different plugins so each platform probably has different behaviour. |
Also, if you want a notification icon to appear while the app is in the foreground (this doesn't happen by default), you should add Also not sure if you've noticed but if you send the phone a second notification then it overwrites the first one. This is as |
ok, cool. So 2/3 points -) Double ECB firing - when you open the App thru App icon then clicking the notification icon -) Then by removing the above part(notificationManager.cancelAll(); ) from onPause. Then that should mean, when you onResume(whatever way) the ECB fires, then deletes the Push Notification tray. And on Pause it does nothing(So it doesnt cause any conflict, thinking there are something to delete). The notID part, yes thats a problem for Android. I heard its not a problem for IOS. But i had been just generating an ID n+1 each time and when it hits 10,000, it starts back from 0. So it kind of patches it up. I will have to let you know about IOS in 2 or 3 days, swamped with work at the moment, and this haha. I also commented on Phonegap forum to ask for some info on upgrading my account, i think its just 9.99 and i will patch this all up,fork this and submit a plugin. |
Yep, I guess cancelling them in onResume would work as well. I think cancelling them in the if block starting on line 74 of PushPlugin.java might be a bit better as you're calling that function a bit less (rather than every time you resume)? But it probably doesn't matter too much. The only issue is that I guess it's a bit confusing for the user. If I'm using an app I don't expect my notifications to disappear when I open the app. I guess it depends on what your app is doing though. A better way might be to not put the extras with the notification intent. That way the notification remains but just acts as a way to open your app. I'll have to have a think about the best way to implement it for what I'm working on. |
Haha yer sorry, i had a plan in my mind, i was only wanting to pay the 9.99 is that i can submit 2 versions for this into Phonegap if they allow me. 2.)And the second version i will keep the notification in the tray and delete the clear tray when onPause. I will keep you updated and on the IOS version as well. But let me know if the cancelling("cancelAll"remove notification tray onResume) causes any conflict(because of the bubbling event,if it happen), if the ECB is not completed the pass through then the delete notification is triggered). Well i think it shouldnt, but if it does, let me know thanks! |
I am still playing with the pushplugin, and i am not sure if it is me, or if it is a general conflict. But my pushplugin doesn't work with Single Instance Launch Mode, only works with SingleTop. |
Hi, it's been a while, i am just wondering if anyone has any experience/knowledge on silent pass through for Android(for phonegap push plugin)? |
Fairly straight forward on Android as you need to explicitly create a notification. Look at GCMIntentService.java. If you just want your Javascript callback function to fire without a notification popping up on the device, just remove the call to |
Cool, thanks, but i am not 100% sure on it though, i am thinking to have the Event call back to trigger even when the phone is in the background,(The phone receives the notification, the user does not touch the phone, but ecb still fires and trigger an Ajax in the App). Also creating a notification and put into the notification tray. Do you mean that? I am a little confused sorry. The PushPlugin.sendExtras(extras); in GCMIntentService.java is the part where it triggers the data from the push to be added into the App right? So i guess if i do this?
|
I am having similar problems with the plugin too. I noticed that the android clear on pause issue might have been a simple mistake on the devs part. I believe the two clear lines (134-135) should be in the resume event instead (which would make for more standard functionality). |
i did the PushPlugin.sendExtras(extras) in GCMIntentService.java and it worked!! Thanks guys this saved my life!... i just im a little confuse about what the Extras mean??? in the documentation of the plugin there is no explanation, i cant find it.... what exactly im sayin to the PushPlugin to do when i put the sendExtras?? |
I fixed this issue here #314 |
This issue is fixed in the new plugin |
Hi everyone, I am new to ionic and using pushPlugin for push notifications. I want to call a function when I receive notification. Currently I am receiving notification and calling function when user tap the notification. How can I achieve this to call a function when I receive notification (means without tapping notification) irrespective of app in foreground/background? any help will be appreciated. Thanks |
@arshad104 go here |
@pawarkishor Thank you for quick response. Can I just clone and replace this plugin? |
@kishorpawar Where can I put the following code?
My code is: `pushNotification = window.plugins.pushNotification;
pushNotification.register(onNotification, errorHandler, config);` I am confused at this point. Please help? |
Last line where you register
On Tue, 13 Dec 2016 at 12:31, arshad104 ***@***.***> wrote:
@kishorpawar <https://github.com/kishorpawar> *Where can I put the
following code?*
if(ALREADY_REGISTERED) { pushNotification.setECB(success, error, {
"senderID" :"SENDER_ID_HERE","ecb": "window.onNotificationGCM" }); } else {
pushNotification.register(success, error, { "senderID"
:"SENDER_ID_HERE","ecb": "window.onNotificationGCM" }); }
*My code is:*
`pushNotification = window.plugins.pushNotification;
window.onNotification = function(e) {
//alert('notification received');
switch(e.event){
case 'registered':
if(e.regid.length > 0) {
device_token = e.regid;
//alert(device_token);
NotificationService.register(device_token).then(function(response){
console.log('registered!');
});
}
break;
case 'message':
//alert('msg received');
NotificationService.acknowledge(e.payload.msg_key).then(function(response){
console.log('acknowledged!');
//alert(JSON.stringify(response));
});
break;
case 'error':
console.log('error occured');
break;
}
};
window.errorHandler = function(error){
console.log('an error occured');
};
pushNotification.register(onNotification, errorHandler, config);`
I am confused at this point. Please help?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#525 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEJnWzq0wBqoDfbZC2piJTZRKuTJDXhZks5rHkLBgaJpZM4D5AUT>
.
--
*Thanks & Regards*
*Kishor Pawar*
*The Trouble with the world is that Stupids are Full of Confidence and
The Intelligent are Full of Doubts.*
|
@kishorpawar Thank you for your help. I am unable to get notification, just getting vibration when notification received, no notification on status bar? what could be the fix? any idea? |
Hi
I am wondering how do i handle onResume functions.
When i resume the app by either clicking on the Icon, the push notifications from the tray, all get wiped, but there are no event call back, none of the message get appeneded, they just disappeared.
For the foreground
if (e.foreground) {
For Resume
would i do
function onResume() {
onNotificationGCM = function(e) {
$("#app-status-ul").append('
}
}
document.addEventListener("resume", onResume, true);
??
The text was updated successfully, but these errors were encountered: