Closed Hrfreire closed 7 years ago
@Hrfreire what version of ti.goosh are you using?
I downloaded the master code yesterday and compiled myself because some erros resolved on commit cfc52c0, after last release.
@Hrfreire does that mean you're using firebase too?
Yes. I'm using firebase. I'm using django-fcm lib: https://django-fcm.readthedocs.io/en/latest/
It works when the app is opened. If the app is in background or closed, the notification arrives, but when user click the notification, the callback function is not fired.
I've tested on my tablet (Samsung galaxy note 8.0) android 4.4.4, and it works when the app is on background but not when the app is closed.
On Motorola moto x 2014 android 6.0 and Xaomi redmi 2 pro android 5.1.1, not working when the app is in background or closed.
I can't replicate this issue. Can you show me the code that are you using to catch notifications?
Thanks.
I have the same problem using FCM, Android 6.0, Ti 6.0.1.GA and Ti.Goosh 2.0.0 (tested 2.0.1 today with no difference at all). It works only with the app open and in foreground.
var TiGoosh = require('ti.goosh');
TiGoosh.registerForPushNotifications({
callback: function(e) {
alert('Received push: ' + JSON.stringify(e));
},
success: function(e) {
deviceToken = e.deviceToken;
Ti.App.Properties.setString('deviceToken', deviceToken);
Ti.API.debug('deviceToken '+deviceToken);
},
error: function(err) {
alert('Failed to register for push notifications! ' + err);
Ti.API.error(err);
}
});
@frazei In which file is written this code? Alloy.js?
I have a file that is called push.js in the root (Resources) that exports a few functions via:
exports.registerAndroid = function() {
and this file is included inside app.js (that's not an alloy project):
var push = require('push');
if (Ti.Platform.Android) {
push.registerAndroid();
I've used this structure for years without any problem, it's the same for ios and it works... Do you think that it can be a problem?
@frazei I don't think so. Could you try to send a minimum part of your project by replicating this structure (only with Push)
Thank you for your help! I've made a simple app only with the push part: https://www.dropbox.com/s/y86l6iu0516bxfa/simplepush.zip?dl=0 While making some more tests I've found out there was an error in the server part (the PHP script was using the "id" property as a varchar, not as a number) and now I can receive notifications even when the app is in background. But the problem still remains if I close (or kill) the app: I do not receive notification at all.
@frazei if you have a Huawei phone, check this issue https://github.com/caffeinalab/ti.goosh/issues/39
@progress44 Yes! You are right... followed the instructions from http://www.androidheadlines.com/2016/01/how-to-fix-missing-notifications-on-huawei-phones.html and now it's working: I really hate Android and all this complications. Thanks @progress44 and @kopiro for your kind support!
@progress44 I just found that the django-fcm module (and FCM console) that I use, send some information inside 'notification' instead 'data' . The notification arrives normally, but the callback is not executed if the app is in background. I forked the django fcm module and edited to send all on 'data' and now it's working normally.
So, probably everyone that uses FCM console will have this problem.
Yeah I imagined that was the case. I'm working on an updated to support FCM as it seems that people are starting to prefer it to GCM Thanks for the information
I have same problem, the app is calling the callback function only if is on foreground. When the app is closed and I click on the notification, the app open, but not execute callback function. Any solution ?
If you are using firebase, send the data notification inside 'data' object. Normally firebase uses 'notification' object to send the data. In my case, change it for data, works.
Yes it's work when app is on foreground or background, but not if it is closed. When the app is closed and I click on the notification, the app open, but not execute callback function.
Finally it's work 😄 with 2.0.2 version (in foreground, in background and when the app is closed) 😃 But not work with 2.0.6 version !
I'm glad you made it work. What was going wrong when it wasn't working before?
When the app is closed and I click on the notification, the app open, but not execute callback function
The app is calling the callback function only if is on foreground. When the app is closed and I click on the notification, the app open, but not execute callback function.