Project: titanium
Issue TIMOB-20111: Android: trayClickFocusedApp event not fired when push notification clicked in tray
When a view is opened and app is placed into background, tapping on a push notification does not fire the trayClickFocusedApp event. This works fine if I don't open a window in the app. However, if even a single window is opened, trayClickFocusedApp stops working (I'm guessing this is due to the fact that there are more than a single activity if windows are opened). In the attached test code, simply comment out the following line and trayClickFocusedApp to start working again: {code:java} win.open(); {code} Steps to reproduce # Create a cloud enabled app #Paste the following into app.js {code:java} var win = Titanium.UI.createWindow({	title: 'Push Test',	backgroundColor: '#fff' }); var login = ""; // Replace with an ACS user login var password = ""; // Replace with an ACS user password // If you comment out this line, everything works as expected win.open(); // -------------------------------------------------------------------------------- // // Push notification stuff // // -------------------------------------------------------------------------------- var CloudPush = require('ti.cloudpush'); CloudPush.debug = true; CloudPush.enabled = true; var deviceToken; var Cloud = require('ti.cloud'); CloudPush.retrieveDeviceToken({	success: function deviceTokenSuccess(e) {	Ti.API.info('Device Token: ' + e.deviceToken);	deviceToken = e.deviceToken;	loginDefault(deviceToken);	},	error: function deviceTokenError(e) {	Ti.API.error('Failed to register for push! ' + e.error);	} }); function loginDefault(e) {	Cloud.Users.login({	login: login,	password: password	}, function(e) {	if (e.success) {	defaultSubscribe();	//Place app in background	Ti.Platform.openURL("http://www.appcelerator.com");	//Send a push in 2 seconds	setTimeout(function() {	Cloud.PushNotifications.notify({	channel: 'message',	payload: {	"badge": 2,	"sound": "default",	"alert": "Push Notification Test",	"icon": "app_icon"	}	}, function(e) {	if (e.success) {	Ti.API.info('Success notify');	} else {	Ti.API.error('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));	}	});	}, 2000);	} else {	Ti.API.error('Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));	}	}); } function defaultSubscribe() {	Cloud.PushNotifications.subscribe({	channel: 'message',	device_token: deviceToken,	type: 'gcm'	}, function(e) {	if (e.success) {	Ti.API.info('Subscribed!');	CloudPush.addEventListener('callback', function(evt) {	Ti.API.info("callback" + JSON.stringify(evt));	alert('got the callback event');	});	CloudPush.addEventListener('trayClickFocusedApp', function(evt) {	Ti.API.info('Tray Click Focused App (app was already running)' + JSON.stringify(evt));	alert('got the trayClickFocusedApp event')	});	} else {	Ti.API.error('Error:' + ((e.error && e.message) || JSON.stringify(e)));	}	}); } {code} # Set your login/password to a valid user (lines 6 & 7) # Launch the app on a device. The app should launch, fire off a push notification then go into the background by launching the browser. # Tap the notification to return to the app. Expected Results The trayClickFocusedApp event listener should run and display a message. Actual Results The trayClickFocusedApp event listener does not run.
Story points: 5