{ "id": "76860", "key": "TIMOB-4489", "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": [ { "id": "11358", "description": "Mobile 1.8.0 M05", "name": "Sprint 2011-26", "archived": true, "released": true, "releaseDate": "2011-07-04" }, { "id": "11570", "description": "", "name": "Release 1.7.2", "archived": true, "released": true, "releaseDate": "2011-07-21" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-06-29T10:08:23.000+0000", "created": "2011-06-23T13:59:37.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "ios" ], "versions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" } ], "issuelinks": [], "assignee": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-07-06T16:42:53.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "This is a testcase to run a background service and creating a local notification. The background service and local notification in the kitchensink example runs fine. But if we include the 'scheduleLocalnotification'(in bg.js) inside a function, the application crashes.\r\n\r\n\r\nStep 1: Copy the following code to app.js\r\n{code:javascript}\r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Tab 1',\r\n backgroundColor:'#fff'\r\n});\r\nwin1.open();\r\n\r\nif (Titanium.Platform.name == 'iPhone OS')\r\n{\r\n// register a background service. this JS will run when the app is backgrounded\r\n\tvar service = Ti.App.iOS.registerBackgroundService({url:'bg.js'});\r\n\t\r\n\tTi.API.info(\"registered background service = \"+service);\r\n\r\n\t// listen for a local notification event\r\n\tTi.App.iOS.addEventListener('notification',function(e)\r\n\t{\r\n\t\tTi.API.info(\"local notification received: \"+JSON.stringify(e));\r\n\t});\r\n\r\n\t// fired when an app resumes for suspension\r\n\tTi.App.addEventListener('resume',function(e){\r\n\t\tTi.API.info(\"app is resuming from the background\");\r\n\t});\r\n\tTi.App.addEventListener('resumed',function(e){\r\n\t\tTi.API.info(\"app has resumed from the background\");\r\n\t});\r\n\r\n\tTi.App.addEventListener('pause',function(e){\r\n\t\tTi.API.info(\"app was paused from the foreground\");\r\n\t});\r\n\t\t\r\n}\r\n{code}\r\nStep 2: Copy the following code in bg.js ( bg.js and app.js under resources folder)\r\n{code:javascript}\r\nTi.API.info(\"hello from a background service\");\r\n\r\nfunction notify(){\r\nvar notification = Ti.App.iOS.scheduleLocalNotification({\r\n\talertBody:\"Application was put in background\",\r\n\talertAction:\"Re-Launch!\",\r\n\tuserInfo:{\"hello\":\"world\"},\r\n\tsound:\"pop.caf\",\r\n\tdate:new Date(new Date().getTime() + 3000) // 3 seconds after backgrounding\r\n});\r\n}\r\n\r\nTi.App.iOS.addEventListener('notification',function(){\r\n\t//Ti.API.info('background event received = '+notification);\r\n\tTi.App.currentService.unregister();\r\n});\r\n\r\nTi.App.currentService.addEventListener('stop',function()\r\n{\r\n\tTi.API.info(\"background service is stopped\");\r\n});\r\n\r\nnotify();\r\n\r\nTi.App.currentService.stop();\r\n{code}\r\n\r\nStep3: Run the app.\r\nStep4: Pause the app using the menu button.\r\nStep5: A notification will be displayed.\r\nStep6: Resume the app by clicking 'Resume' on notification alert.\r\nStep7: Application crashes.\r\n\r\nh2. Tested On\r\niOS 4.3, TiSDK 1.7.1\r\n\r\nWorks fine on 1.6.2\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "iOS: Including 'scheduleLocalnotification' inside a function results in application crash", "creator": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "iOS 4.3 and Ti 1.7.0", "comment": { "comments": [ { "id": "158246", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Code reviewed, functional test, merged master and 1.7.x", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-29T10:08:23.000+0000", "updated": "2011-06-29T10:08:23.000+0000" }, { "id": "158836", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Fixed with iOS simulator and iPhone 4 verizon (4.2.8), iPhone 4 (4.3.3), iPod 3rd Gen (4.0.2). SDK 1.7.x r177ece80", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-07-06T16:42:53.000+0000", "updated": "2011-07-06T16:42:53.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }