[TIMOB-20226] iOS 9.3: Support new WatchConnectivity features
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-04-07T09:22:17.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.4.0 |
Components | iOS |
Labels | qe-5.4.0, watch |
Reporter | Hans Knöchel |
Assignee | Hans Knöchel |
Created | 2016-01-12T10:48:42.000+0000 |
Updated | 2016-08-08T17:10:21.000+0000 |
Description
iOS 9.3 introduces some new API's of the WatchConnectivity framework:
- WCSession.activationState
- \[WCSessionDelegate session:activationDidCompleteWithState:error:]
- \[WCSessionDelegate sessionDidBecomeInactive:]
- \[WCSessionDelegate sessionDidDeactivate:]
- WCSessionActivationState
- WCSessionActivationStateActivated
- WCSessionActivationStateInactive
- WCSessionActivationStateNotActivated
That will simply result in new events to be used to check the session state from the main application.
PR: https://github.com/appcelerator/titanium_mobile/pull/7722 Demo:
I tried to FR this but, it doesn't seem to work, and it gets stuck at:
Here's how to reproduce: (With Xcode 7.3 installed) 1. I scons'ed the PR. 2. I installed the scon'sed package. 3. *ti create* 4. in tiapp.xml make sure it's sdk version is the one i must installed 5. in project folder, *ti create --type applewatch* 6. *ti build -p ios --launch-watch-app*
This is weird..Are you sure it is related to the PR and works without? Will re-validate tomorrow.
[~hansknoechel] TIMOB-20489 should not affect this.
[~hansknoechel] the way I'm reading [Apple's docs](https://developer.apple.com/library/watchos/documentation/WatchConnectivity/Reference/WCSession_class/index.html#//apple_ref/doc/uid/TP40015237-CH1-SW56) you don't *need* to support the _\*active_ methods. I wonder if - by adding these to
Ti.WatchSession
we actually *require* developers to implement the events on iOS side and the same methods on WatchOS side. That would make it a breaking change. Can't we make it optional? Only implement these methods if the events are used in the Titanium source code? {quote} If your delegate does not implement the appropriate methods for asynchronous activation and activation state changes, your app opts out of multiple Apple Watch support altogether. Opting out has important implications for your app when the user switches from one Apple Watch to another. When a switch occurs, your app’s session is deactivated. When your app subsequently moves to the background, the system terminates your app. (Background execution modes do not prevent the termination of your app.) The next time your app launches, it connects with the new Apple Watch. {quote}Which required methods do you mean? As far as I know, I only added new events and constants to track the state, didn't override something that could cause the above scenario.
If your iOS and/or (important unclarity) WatchOS2 app does not implement the new methods iOS will terminate your iOS app when you background it after the user has switched to a new Apple Watch. The when you reopen the iOS app it will connect to the new Apple Watch. If we implement these new methods in the Titanium SDK but the developer does not update his code to actually use them (the new events) then we might get unpredictable results. If iOS will only enable asynchronously activation if both the iOS and WatchOS2 app (which seems to be the case, but I don't find the documentation 100% clear on that) then we're good, but we should check.
Verified as fixed, was able to receive all 3 activationStates:
Ti.WatchSession.ACTIVATION_STATE_NOT_ACTIVATED
: Unpaired watch.Ti.WatchSession.ACTIVATION_STATE_INACTIVE
: Switching paired watch to a secondary watch.Ti.WatchSession.ACTIVATION_STATE_ACTIVATED
: Paired watch. Tested On: iPhone 6S (9.3.3) Device Apple Watch (2.2.2) Mac OSX El Capitan 10.11.6 Ti SDK: 5.4.0.v20160804185318 Appc Studio: 4.7.0.201607250649 Appc NPM: 4.2.7 App CLI: 5.4.0-40 Xcode 7.3.1 Node v4.4.7 *Closing ticket.*