{ "id": "137861", "key": "AC-1646", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "11", "description": "Is not a bug in our product", "name": "Not Our Bug" }, "resolutiondate": "2014-10-13T00:01:42.000+0000", "created": "2014-10-09T14:24:23.000+0000", "labels": [ "ios8", "notification" ], "versions": [], "issuelinks": [], "assignee": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "updated": "2016-03-08T07:38:07.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Question : Is it possible to make a HTTP call and update the data in background when the user clicks on accept button from the interactive notification (without launching the app / bring it foreground if it already running)? \r\n\r\n{code:title=app.js|borderStyle=solid}\r\nTi.API.info(\"app launched\");\r\n\r\nTi.App.iOS.addEventListener('localnotificationaction', function(e) {\r\n\tif (e.category == \"DOWNLOAD_CONTENT\" && e.identifier == \"ACCEPT_IDENTIFIER\") {\r\n\t\tvar url = \"http://www.appcelerator.com\";\r\n\t\tvar client = Ti.Network.createHTTPClient({\r\n\t\t\tonload : function(e) {\r\n\t\t\t\tTi.API.info(\"Received text: \" + this.responseText);\r\n\t\t\t},\r\n\t\t\tonerror : function(e) {\r\n\t\t\t\tTi.API.debug(e.error);\r\n\t\t\t\talert('error');\r\n\t\t\t},\r\n\t\t\ttimeout : 5000\r\n\t\t});\r\n\t\tclient.open(\"GET\", url);\r\n\t\tclient.send();\r\n\t\tTi.App.Properties.setString(\"dataupdated\", new Date().getTime());\r\n\t}\r\n});\r\n\r\nvar acceptAction = Ti.App.iOS.createUserNotificationAction({\r\n\tidentifier : \"ACCEPT_IDENTIFIER\",\r\n\ttitle : \"Accept\",\r\n\tactivationMode : Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,\r\n\tdestructive : false,\r\n\tauthenticationRequired : true\r\n});\r\nvar rejectAction = Ti.App.iOS.createUserNotificationAction({\r\n\tidentifier : \"REJECT_IDENTIFIER\",\r\n\ttitle : \"Reject\",\r\n\tactivationMode : Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,\r\n\tdestructive : true,\r\n\tauthenticationRequired : false\r\n});\r\nvar downloadContent = Ti.App.iOS.createUserNotificationCategory({\r\n\tidentifier : \"DOWNLOAD_CONTENT\",\r\n\tactionsForDefaultContext : [acceptAction, rejectAction]\r\n});\r\nTi.App.iOS.registerUserNotificationSettings({\r\n\ttypes : [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND],\r\n\tcategories : [downloadContent]\r\n});\r\n\r\n// App UI\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : 'white'\r\n});\r\nvar label = Ti.UI.createLabel({\r\n\ttop : 30,\r\n\ttext : \"Last update : \" + Ti.App.Properties.getString(\"dataupdated\")\r\n});\r\nwin.add(label);\r\nvar button = Ti.UI.createButton({\r\n\ttitle : 'Trigger Notification'\r\n});\r\nbutton.addEventListener('click', function(e) {\r\n\tvar note = Ti.App.iOS.scheduleLocalNotification({\r\n\t\tdate : new Date(new Date().getTime() + 3000),\r\n\t\talertBody : \"New content available! Download now?\",\r\n\t\tbadge : 1,\r\n\t\tuserInfo : {\r\n\t\t\t\"url\" : \"http://www.download.com/resource/asset.json\",\r\n\t\t\tid : \"1\"\r\n\t\t},\r\n\t\tcategory : \"DOWNLOAD_CONTENT\"\r\n\t});\r\n});\r\nwin.add(button);\r\nwin.open();\r\n\r\n{code}\r\n\r\nh4. Test Case 1: \r\n\r\n1. Open the app, it asked for notification permissions. I clicked OK. \r\n2. The label on the top was saying \"Last update : null\" \r\n3. Clicked on the \"Trigger Notification\" button, then pressed the home button to send the app to background. \r\n4. After 3 seconds I got banner notification appearing on the top, I clicked accept. \r\n5. I could see, some html was printed on the console log. \r\n6. Exit the app and launched it again, The label on the top was saying \"Last update : 1412854520621\" - meaning I was able to make the http call in the background as my app was running in background. \r\n\r\nh4. Test Case 2: \r\n\r\n1. Clicked on the \"trigger notification\" button, then double tapped the home button, removed the app from background. \r\n2. After 3 seconds I got banner notification appearing on the top, I clicked accept. \r\n3. I could see only the followings on my console log. \r\n\r\n{code:title=console (My project name is push)|borderStyle=solid}\r\n\r\n[INFO] : push/1.0 (3.4.0.b54c467) \r\n[INFO] : app launched \r\n\r\n{code}\r\nMeaning, it tried to execute but failed. \r\n\r\n*I guess it should act in the same way even if the app is not running in background. Isn't?* If not how to handle such cases?", "attachment": [], "flagged": false, "summary": "iOS 8 Interactive Notification - Not working when app is not running", "creator": { "name": "mano_mykingdom", "key": "mano_mykingdom", "displayName": "Manojkumar Murugesan", "active": true, "timeZone": "Asia/Kolkata" }, "subtasks": [], "reporter": { "name": "mano_mykingdom", "key": "mano_mykingdom", "displayName": "Manojkumar Murugesan", "active": true, "timeZone": "Asia/Kolkata" }, "environment": "Titanium Studio and SDK : 3.4.0.GA\r\nXCode : 6.0.1\r\niPhone 5s with iOS 8.0", "comment": { "comments": [ { "id": "327790", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "This is more related to the way to handle a notification. Once you click on the dialog, you are able to request the app to open at certain window, but you can't start a process in the background like that. ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2014-10-13T00:01:42.000+0000", "updated": "2014-10-13T00:01:42.000+0000" }, { "id": "327821", "author": { "name": "mano_mykingdom", "key": "mano_mykingdom", "displayName": "Manojkumar Murugesan", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Thanks for the clarification.", "updateAuthor": { "name": "mano_mykingdom", "key": "mano_mykingdom", "displayName": "Manojkumar Murugesan", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2014-10-13T07:00:31.000+0000", "updated": "2014-10-13T07:00:31.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }