{ "id": "150878", "key": "TIMOB-19446", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "14826", "description": "Release 5.1.0-remaining iOS9 features, Android M features", "name": "Release 5.1.0", "archived": false, "released": true, "releaseDate": "2015-11-20" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-09-25T17:12:09.000+0000", "created": "2015-09-01T13:17:58.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "watchOS2" ], "versions": [], "issuelinks": [ { "id": "50041", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "153615", "key": "TIDOC-2390", "fields": { "summary": "iOS: Ti.WatchSession.sendMessage is incorrect for 5.1.x", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2015-12-04T09:16:34.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": "Right now, I have to add a session delegate to receive a message back from the device. It took me a little bit to realize this. I was using this: https://developer.apple.com/library/prerelease/watchos/documentation/WatchConnectivity/Reference/WCSession_class/index.html#//apple_ref/occ/instm/WCSession/sendMessage:replyHandler:errorHandler:\r\n\r\nExpecting to use the reply block.", "attachment": [], "flagged": false, "summary": "iOS9: Support block callback on watchOS 2", "creator": { "name": "rblalock", "key": "rblalock", "displayName": "Rick Blalock", "active": false, "timeZone": "America/Havana" }, "subtasks": [], "reporter": { "name": "rblalock", "key": "rblalock", "displayName": "Rick Blalock", "active": false, "timeZone": "America/Havana" }, "environment": null, "closedSprints": [ { "id": 485, "state": "closed", "name": "2015 Sprint 19 SDK", "startDate": "2015-09-12T00:30:29.539Z", "endDate": "2015-09-26T00:30:00.000Z", "completeDate": "2015-09-28T02:29:14.458Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "362087", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "The common problem is, that the callback block is called on the device but not using the simulator (the session delegate is called). Reference: https://forums.developer.apple.com/thread/7315", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-09-02T19:21:00.000+0000", "updated": "2015-09-02T19:21:00.000+0000" }, { "id": "363771", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "PR here: https://github.com/appcelerator/titanium_mobile/pull/7179\r\n\r\nh4. sample code to send message with block function\r\n{code}\r\n Ti.WatchSession.sendMessage({\r\n message: {\r\n message: 'Hi',\r\n from: 'app',\r\n type: 'message' \r\n },\r\n onReply: function(e) {\r\n eventsArea.value += '\\nreceive immediate message reply '\r\n + '\\n' + JSON.stringify(e); \r\n }\r\n });\r\n{code}\r\n\r\nTo see complete implementation on watch <-> titanium app, see\r\nhttps://github.com/cheekiatng/Titanium-WatchOS2-Sample-App/tree/replyHandler\r\n", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-09-14T09:37:02.000+0000", "updated": "2015-09-14T09:57:27.000+0000" }, { "id": "365016", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR approved, thank you!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-09-25T17:12:02.000+0000", "updated": "2015-09-25T17:12:02.000+0000" }, { "id": "369456", "author": { "name": "htbryant", "key": "htbryant", "displayName": "Harry Bryant", "active": true, "timeZone": "Europe/London" }, "body": "Verified fixed, however in order for the sample code to work correctly, {{onReply}} was changed to {{reply}}. After making this change, I was able to send message from device to watch, whereas previously it would cause the Watchkit app to crash. Also verified that the documentation states the correct Callback parameter as {{reply}} : \r\n\r\nhttps://docs.appcelerator.com/platform/latest/#!/api/Titanium.WatchSession-method-sendMessage\r\n\r\nOther than possibly updating the WatchKit Sample App [~cng] I have no issue with the above ticket and am happy to close it. [~hansknoechel] has recommended that we implement a deprecated message for the old sendMessage without Callback, instead of crashing the app without warning.\r\n\r\nTested on: iPhone 6S Plus Device & Simulator iOS 9.1, WatchOS 2.0.1.\r\nMac OSX El Capitan 10.11 (15A284)\r\nTi SDK: 5.1.0.v20151104190037 \r\nAppc NPM: 4.2.1\r\nAppc CLI: 5.1.0-44\r\nTi CLI: 5.0.4\r\nAlloy: 1.7.24\r\nXcode 7.1(7B91b)\r\nNode v0.12.7\r\nproduction\r\n", "updateAuthor": { "name": "htbryant", "key": "htbryant", "displayName": "Harry Bryant", "active": true, "timeZone": "Europe/London" }, "created": "2015-11-09T21:37:36.000+0000", "updated": "2015-11-09T21:37:36.000+0000" }, { "id": "372160", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "The documentation is different from the implementation:\r\nhttp://docs.appcelerator.com/platform/latest/#!/api/Titanium.WatchSession-method-sendMessage\r\n\r\nThe documentation says the callback should be passed as the second argument, which I must say I like better then the implementation which changes the first argument into a dictionary that has message and reply:\r\nhttps://github.com/appcelerator/titanium_mobile/blob/bc85170157d3bebc5de1d61a9fe6e34bce84a8c9/iphone/Classes/WatchSessionModule.m#L158-L162\r\n\r\nI'll create a ticket to fix the docs, but may I ask why we've chosen this implementation of the what was documented?", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-12-04T09:05:48.000+0000", "updated": "2015-12-04T09:05:48.000+0000" }, { "id": "372161", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "The breaking change is done in this commit:\r\nhttps://github.com/appcelerator/titanium_mobile/commit/1d8aee1d2e4862d3d81271aff8ad836b2b09260a#diff-c8e5ac73085caff0252e3086f1c970e3L111\r\n\r\nA workaround that works with both Ti 5.0 and 5.1 would be:\r\n\r\n{code}\r\nvar message = {\r\n\tfoo: 'bar'\r\n};\r\nmessage.message = message;\r\nTi.WatchSession.sendMessage(message);\r\n{code}", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-12-04T09:16:34.000+0000", "updated": "2015-12-04T09:16:34.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }