Skip to content
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 received when app is closed. #39

Closed
argum opened this issue Jan 25, 2017 · 9 comments
Closed

Notification not received when app is closed. #39

argum opened this issue Jan 25, 2017 · 9 comments

Comments

@argum
Copy link

argum commented Jan 25, 2017

Hello to all! First I want to thank you for this awesome module. It works better than ACS API and ArrowDB!

Second, I have a problem with a Android 6.0.0 device (Huawei P9) and:
Titanium SDK : 5.5.1
ti.goosh : 1.6.2

I send a push notification through FCM api:

$url = 'https://fcm.googleapis.com/fcm/send';

When the app is opened or in background, the notification are received as expected, but when I close the app (killed from multitasking window) and send a notification again, FCM return success: 1 (as expected) but the notification banner never appears in the phone.

Am I doing anything wrong? My app code is really easy, is the same as your example in the module :)

var TiGoosh = require('ti.goosh');
TiGoosh.registerForPushNotifications({

// The callback to invoke when a notification arrives.
callback: function(e) {
    //var data = JSON.parse(e.data || '');
    Ti.API.error(e);
},

// The callback invoked when you have the device token.
success: function(e) {
    // Send the e.deviceToken variable to your PUSH server
    Ti.API.error('Notifications: device token is ' + e.deviceToken);
},

// The callback invoked on some errors.
error: function(err) {
    Ti.API.error('Notifications: Retrieve device token failed', err);
}

});

Thanks again for your awesome job!

Pau.

@progress44
Copy link
Contributor

Can you try upgrading both Titanium SDK to 6.0.0.GA and ti.goosh to version 2.0? We may have fixed the problem in this version. If it persists let us know and we'll look at it thoroughly

@argum
Copy link
Author

argum commented Jan 26, 2017

Hello progress44, thanks for your response.

I have updated my SDK to 6.0.1 and also the ti.goosh library to the 2.0.0. The same problem happens.

Just a note, my phone has the Google Play Services 10.0.84 but, every time I compile the app with ti.goosh, i read the following error on the console:

[ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

This may be related to the main issue?

Also, when I use other code (Ti.cloudpush ... ) when i close the app and send a push notification throught ACS API, the notification is not received but i get the next message in the console:

[WARN] : W/GCM-DMM (22054): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=d2app.idisc.es (has extras) }

I do not receive this warning in ti.goosh code but I think that the problem is the same.

I have also, with ti.cloudpush, receive the "GooglePlayServicesUtil: The Google Play services resources were not found..."

This does not happens with all devices, but in some yes. A device which this behaviour happens is a Huawei P9 (marshmallow 6.0.0), a device which does not happens is a BQ Aquaris E5 (Android 5.0.0)

Anyone can help me to solve it? Thanks!

@progress44
Copy link
Contributor

I'll work on the module next week and I'll test this behaviour although I'm guessing it may be a permissions limit on the OS side. Try checking the settings and see if there are any particular permissions you need to enable for the app.

@argum
Copy link
Author

argum commented Jan 26, 2017

Right now I have tested the same code, same SDK (6.0.0) same ti.goosh version (2.0.0) in a Samsung Galaxy S7 Edge and everything works as expected. The push notification is received when the app is closed, opened or in the background.

But I have also received the error: GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

Like the other device Huawei P9.

Thanks progress44 for your quick response and awesome job. If you need more info, please tell me and I will send you as many info you need. Thanks!

@progress44
Copy link
Contributor

You can ignore the error message GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. It doesn't necessarily mean they're not found :)

@argum
Copy link
Author

argum commented Jan 26, 2017

For the record, this is the config I can change in my phone related to push notifications for each app "FCM" app is this app.

Best Regards!

screenshot_2017-01-26-10-38-08

@progress44
Copy link
Contributor

Thanks! We'll look into it.

@argum
Copy link
Author

argum commented Jan 27, 2017

Hello Progress44, late yesterday my customer send a example list of a devices which didn't receive a push notification. Most of the devices are Huawei. I google it and I found several articles with this error.

Huawei has a option called "Protected Apps". If an app is not a protected app, when the app is closed, Huawei closes the listener for this app and the notification is rejected by the phone. So, when i put my app to a protected app, the push notification was received even the app is closed.

http://www.androidheadlines.com/2016/01/how-to-fix-missing-notifications-on-huawei-phones.html

Thanks for your big support! I will test it a little more and find a way to integrate it with ti.map and other modules I need for my app.

Thanks again!

Best Regards,

Pau.

@progress44
Copy link
Contributor

@argum Thanks for letting us know of this. It's really helpful to us as well. In the repo you can find out how to make it work with ti.map as well.
Ani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants