Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17945] Android: CloudPush - events not fired correctly

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-01-06T21:43:20.000+0000
Affected Version/sRelease 3.4.0, Release 3.5.0
Fix Version/sRelease 3.5.0, Release 4.0.0
ComponentsAndroid
LabelsTCSupport, qe-3.4.1, qe-3.5.0
ReporterShawn Lan
AssigneeJon Alter
Created2014-08-30T01:27:40.000+0000
Updated2015-01-06T21:43:20.000+0000

Description

Problem Description

If CloudPush.singleCallback is set to true, "callback" event will not be fired when clicking the tray notification that launches the app (app wasn't in the foreground nor the background). Without CloudPush.singleCallback set to true, "callback" will be fired as expected. trayClickFocusedApp and trayClickLaunchedApp are never fired in any case.

Testcase

1. Create a new mobile project (classic titanium) 2. Paste this to app.js
var CloudPush = require('ti.cloudpush');
CloudPush.retrieveDeviceToken({
    success: function deviceTokenSuccess(e) {
        // Use this device token with Ti.Cloud.PushNotifications calls
        // to subscribe and unsubscribe to push notification channels
        Ti.API.info('Device Token: ' + e.deviceToken);
    },
    error: function deviceTokenError(e) {
        alert('Failed to register for push! ' + e.error);
    }
});
// These events monitor incoming push notifications
CloudPush.addEventListener('callback', function (evt) {
    alert(evt.payload);
});
CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
    Ti.API.info('Tray Click Launched App (app was not running)');
});
CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
    Ti.API.info('Tray Click Focused App (app was already running)');
});
3. Run in device.

OBSERVED PROBLEM

After Enabling "ti.cloud" and "ti.cloudpush" in the project, we provided the Production and Development Key generated by titanium and also the ACS API key from web console in the "tiapp.xml" file.
<property name="acs-api-key-development" type="string">W4dRrpUDB86lWmDP8xUQvFT8GYSba0Py</property>
<property name="acs-api-key-production" type="string">vLJOUvCtWkNZISxsLJnovTUpsYFpE3BY</property>
<property name="acs-api-key" type="string">W4dRrpUDB86lWmDP8xUQvFT8GYSba0Py</property>
We also configured the app for GCM protocol. After Running the app. An error message has shown and though GCM Authentication was successful, The Device token was not shown in the console.

Error Message

[ERROR] :  SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file
[INFO] :   TiApplication: (main) [0,0] checkpoint, app created.
[INFO] :   TiApplication: (main) [210,210] Titanium 3.3.0 (2014/07/11 12:36 787cd39)
[ERROR] :  SELinux:
[ERROR] :  SELinux: Function: selinux_android_load_priority [1], There is no sepolicy version file
[ERROR] :  SELinux:
[ERROR] :  SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts

Comments

  1. Jason Priebe 2014-11-03

    Is there any reason this couldn't go into 3.4.1 or 3.4.2? We need this fix urgently, and I'm concerned that 3.5.0 might be too far away for our release schedule.
  2. Ingo Muschenetz 2014-11-03

    I've placed it into 3.4.3. As it is a module, it should be available in advance of that.
  3. Jason Priebe 2014-11-03

    Thanks!
  4. Jason Priebe 2014-11-11

    Is there any way to get a preview of this module? I can't get a continuous build of 3.4.3 yet, and it doesn't appear to have been added to 3.5.0's continuous builds. We would be very happy to test and report back any findings.
  5. Patrick van Vuuren 2014-11-11

    This counts for me as well. I really need a working version soon as we're trying to deploy apps with push notifications. Currently I am failing on the part that if my app is closed and I open it with the notification, that the event is not fired.
  6. Ingo Muschenetz 2014-11-11

    Hi All, we are planning on working on this this sprint (next two weeks). Once the work is completed, you should be able to download an updated module.
  7. Jon Alter 2014-11-12

    Testing with Wilson shows that the issue is only when singleCallback=true
  8. Shawn Lan 2014-11-12

    "trayClickFocusedApp and trayClickLaunchedApp are never fired" whether singleCallback set to true or false.
  9. Jason Priebe 2014-11-13

    I don't believe Shawn's comment to be accurate. Our testing shows that the trayclick events *do* fire with singlecallback set to false (you just can't tell which notification was actually clicked on). There are a couple of other JIRA issues that have been fixed recently: TC-4895 TIMODOPEN-440 TIMODOPEN-440 could be to blame for what Shawn is seeing.
  10. Shawn Lan 2014-11-13

    I tested on 3.4.0
  11. Jason Priebe 2014-11-13

    Whatever version of the mobile SDK you are using, make sure you're using ti.cloudpush 3.3.1. We got access to it a couple of weeks ago via continuous builds. But it's part of mobilesdk 3.4.1, I believe.
  12. Patrick van Vuuren 2014-11-14

    I am also getting this error CloudpushModuleImplementation: (KrollRuntimeThread) [691,691] Problem parsing acs-push-api-url: java.net.MalformedURLException Cloudpush version 3.3.2
  13. Jason Priebe 2014-11-18

    When we updated to mobilesdk version 3.4.1, we noticed that Cloudpush 3.3.4 was bundled. Thank you for accelerating this! We did some testing, and it still seems like we're not getting events fired as expected. With singleCallback set to true: App in background: - click on notification tray icon - app is brought to foreground - trayClickFocusedApp event fired - callback fired App stopped: - click on notification tray icon - app is launched - trayClickLaunchedApp event fired - callback *not* fired Our app needs the callback function to get access to the push notification payload. I'd love it if it were also passed to trayClickFocusedApp and trayClickLaunchedApp, but it's not. When we see trayClickFocusedApp or trayClickLaunchedApp, we set a flag so that when the callback comes in, we automatically open a screen in the app based on the payload. If we get callback without trayClickFocusedApp or trayClickLaunchedApp, we assume the user is interacting with the app, so we don't change anything in the UI. Without the callback getting called, we can't do any of this. This is an urgent fix for us. I can open a support ticket if need be.
  14. Patrick van Vuuren 2014-11-22

    Seeing the issue is resolved, when will it come available? Waiting for 3.6.0 (March) is way too long for our current product. Regards, Patrick
  15. Jon Alter 2014-11-24

    Hi [~Serfenia], the version of ti.cloudpush that contains this fix (v3.3.5) can be found here: https://github.com/appcelerator/titanium_mobile/raw/master/support/module/packaged/ti.cloudpush-android-3.3.5.zip
  16. Patrick van Vuuren 2014-11-25

    Hello Jon, I've downloaded and included the 3.3.5 version which includes the fix. I've put a log inside the trayClickLaunchedApp event. When I start my app from the notification with singleCallback on true this event is not fired, however 'callback' is fired. (I checked the logs with DDMS, could not find my trayClickLaunchedApp log, but found my callback logs) Without singleCallback it has the same behaviour. I expect trayClickLaunchedApp to fire when the app is previously closed by the user. It should do that right? and when the app is in android terms 'paused', the focus event should be called. Just to clarify we are on the same line :). Regards, Patrick Tested on (exact same behaviour): Android 4.3 - Samsung Galaxy S3 Android 5.0 - Nexus 9
  17. Jason Priebe 2014-11-25

    We're testing ti.cloudpush 3.3.5 with mobile SDK 3.4.2.v20141027085717. We use singleCallback=true, and we are getting the trayClickLaunchedApp event. Thank you to the Appcelerator devs who added the push notification payload to trayClickFocusedApp and trayClickLaunchedApp. This makes the logic to handle pushes *much* simpler!
  18. Patrick van Vuuren 2014-11-25

    Hello Jason, Can you confirm it does not fire with Ti SDK 3.4.1? Also if it works with Ti SDK 3.4.2, could you give me a link to a stable build of it? Regards, Patrick
  19. Jason Priebe 2014-11-25

    I just rebuilt with 3.4.1, and trayClickLaunchedApp *does* fire. I don't have a release version of 3.4.2, but I get builds here: http://builds.appcelerator.com.s3.amazonaws.com/index.html#3_4_X We have been doing all our development and testing with a 3.4.2 continuous build. If it hasn't gone to GA when we're ready for our final QA, we may have to release our app with a continuous build.
  20. Patrick van Vuuren 2014-11-25

    Allright I have found the problem why it does not fire for me. I have the notification handling placed in a CommonJS module. I added the events for handling the trayClickLaunchedApp and trayClickFocusedApp and callback in that CommonJS module. The focus and callback just work, the launch does not. If I place it inside my alloy.js, it works. I am not sure if it's supposed to do that, but at least I can get it working now. Developers, *Thanks Alot*
  21. Jason Priebe 2014-11-25

    Strange. Our push notification handling code is also inside a CommonJS module, and we're not having any trouble with it. I *have* seen weird things that don't work inside of CommonJS modules (notably around opening the app via a custom URL scheme and trying to access Ti.Android.currentActivity from within a CommonJS module). But this one isn't giving us any problems.
  22. Shawn Lan 2014-11-26

    With SDK 3.4.1 I also got the following errors: [ERROR] : CloudpushModuleImplementation: (KrollRuntimeThread) [138,231] Problem parsing acs-push-api-url: java.net.MalformedURLException [ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. The Push Notification seems working fine. Should I ignore the errors above?
  23. Jon Alter 2014-12-02

    [~shawnlan] The 1st error that you are seeing is important. [ERROR] : CloudpushModuleImplementation: (KrollRuntimeThread) [138,231] Problem parsing acs-push-api-url: java.net.MalformedURLException I am guessing you have a 'acs-push-api-url' property set in your tiapp.xml. Would you mind posting that property here? The 2nd error can be safely ignored. [ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
  24. Shawn Lan 2014-12-02

    For the 1st error: no I didn't set 'acs-push-api-url' property in tiapp.xml. I have no idea where that comes from. The only properties I set in tiapp.xml regarding cloudpush are: acs-api-key-production acs-api-key-development acs-grouped-notification-message The error isn't showing in previous SDKs. Should be something in 3.4.1.
  25. Jon Alter 2014-12-02

    Hi [~shawnlan], It turns out that error isn't a problem either. I have fixed it so that it will not be unnecessarily displayed like it is right now, and that will be in a future release. Thank you for the help.
  26. Wilson Luu 2015-01-05

    Reopening ticket. I am seeing this new behavior with the latest 3.5.0 stack: ||App State||singleCallback||trigger callback||trigger trayClickFocusedApp||trigger trayClickLaunchedApp|| |*killed*|*true*|(+)|*NA*|(-)| |*killed*|*false*|(+)|*NA*|(-)| |foreground|true|(+)|NA|NA| |background|true|(+)|(+)|NA| |foreground|false|(+)|NA|NA| |background|false|(+)|(+)|NA| Tested on: Appcelerator Studio, build: 3.4.1.201410281743 SDK build: 3.5.0.v20141222103320 ti.cloud: 3.2.7 ti.cloudpush: 3.3.7 CLI: 3.4.1 Alloy: 1.5.1 Devices: Samsung Galaxy S4 (4.4.2), Nexus 5 (5.0)
  27. Wilson Luu 2015-01-05

    Also, tried the above scenario (i.e. app is killed and singleCallback is set to true or false) with APS SDK 1.0.2 and *was not* able to reproduce the issue; both the onCallback and onLaunchedApp methods get called.
  28. Patrick van Vuuren 2015-01-06

    Hey Wilson, Ye I noticed the same issue, currently I have an app in producten that has this issue. When the user kills the app through the multitask window, that app is launched but hangs on splash screen. Though, on Android 5 this does not seem the case. Regards, Patrick
  29. Wilson Luu 2015-01-06

JSON Source