{ "id": "148979", "key": "TIMOB-19050", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2015-07-01T22:39:15.000+0000", "created": "2015-06-20T00:13:11.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "supportTeam" ], "versions": [], "issuelinks": [], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-22T21:46:00.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h3. Issue\r\n\r\nWhen calling an intent the onNewIntent event is not being thrown.\r\n\r\nh3.Test case\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({fullscreen:false});\r\n \r\n//create some simple UI\r\nvar textfield = Ti.UI.createTextField({width:300, height:'auto', top:40, left:20, hintText:'enter message'});\r\nvar button = Ti.UI.createButton({title:'Send Notification', width:'auto', top:120, left:20, height:'auto'});\r\nvar label = Ti.UI.createLabel({width:'auto', top:200, left:20, height:'auto', width:200, text:'Message from intent:'});\r\nvar msgLabel = Ti.UI.createLabel({width:'auto', top:240, left:20, height:'auto', width:200, backgroundColor:'lightgrey', text:'---'});\r\n \r\nwin.add(textfield);\r\nwin.add(button);\r\nwin.add(label);\r\nwin.add(msgLabel);\r\n \r\nwin.addEventListener(\"open\", function(evt) {\r\n button.addEventListener(\"click\", function(evt) {\r\n //handle the pending intent from the notification bar\r\n win.activity.addEventListener(\"newIntent\", function(evt)\r\n {\r\n var pushObjStr = evt.intent.getStringExtra(\"pushReceived\"); // ***** GET\r\n if (pushObjStr) {\r\n Ti.API.debug(\"received data: \" + pushObjStr);\r\n msgLabel.text = pushObjStr;\r\n } else {\r\n Ti.API.debug(\"no data received\");\r\n msgLabel.text = \"no data received\";\r\n }\r\n });\r\n \r\n Ti.UI.Android.hideSoftKeyboard();\r\n msgLabel.text = \"---\"; //reset any previous text value\r\n \r\n //grab the user input\r\n var message = textfield.value;\r\n if (!message) {\r\n alert('you must provide a message');\r\n return;\r\n } else {\r\n //clear out what was typed\r\n textfield.value = '';\r\n }\r\n \r\n //put some custom data into an intent\r\n var intent = Ti.Android.createIntent(\r\n {\r\n action: Ti.Android.ACTION_MAIN,\r\n flags: Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP,\r\n className: \"org.appcelerator.titanium.TiActivity\",\r\n packageName: Ti.App.id\r\n });\r\n intent.addCategory(Ti.Android.CATEGORY_LAUNCH);\r\n intent.putExtra(\"pushReceived\", message); //***** PUT\r\n \r\n //a pending intent to send open an activity when launched \r\n var pending = Ti.Android.createPendingIntent(\r\n {\r\n activity: win.activity,\r\n intent: intent,\r\n //updateCurrentIntent: false,\r\n type: Ti.Android.PENDING_INTENT_FOR_ACTIVITY\r\n });\r\n \r\n //put a notification in the notification bar \r\n var notification = Ti.Android.createNotification(\r\n {\r\n contentIntent: pending,\r\n contentTitle: \"New Notification\",\r\n contentText: \"Msg: \" + message,\r\n tickerText: \"New Notification\"\r\n });\r\n Ti.Android.NotificationManager.notify(1, notification);\r\n });\r\n \r\n});\r\n \r\nwin.open();\r\n{code}\r\n\r\nh3. Steps to reproduce\r\n\r\n1. Run the test case\r\n2. Introduce a message in the textfield \r\n3. Press the send button\r\n\r\nExpected Result\r\nAfter receiving the local notification the message textfield will throw the newIntent event and show the sent message or a \"No data received\" message\r\n\r\nActual Result\r\nThe newIntent event is not thrown \r\n", "attachment": [], "flagged": false, "summary": "Android: onNewIntent event not being thrown", "creator": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 429, "state": "closed", "name": "2015 Sprint 13 SDK", "startDate": "2015-06-23T05:39:59.141Z", "endDate": "2015-07-04T00:30:00.000Z", "completeDate": "2015-07-07T04:59:44.220Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "356628", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is working as expected. You need to click on the notification for the pendingIntent to activate. Sending a notification by calling notify() alone does not trigger the pendingIntent. In this example, you would do:\r\n1. Introduce a message in the textfield\r\n2. Press the button\r\n3. Click on the newly received notification.\r\n4. New data received.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-07-01T22:38:53.000+0000", "updated": "2015-07-01T22:38:53.000+0000" }, { "id": "415035", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid with reference to previous comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-22T21:46:00.000+0000", "updated": "2017-03-22T21:46:00.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }