Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20226] iOS 9.3: Support new WatchConnectivity features

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-04-07T09:22:17.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsiOS
Labelsqe-5.4.0, watch
ReporterHans Knöchel
AssigneeHans Knöchel
Created2016-01-12T10:48:42.000+0000
Updated2016-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.

Comments

  1. Hans Knöchel 2016-02-14

    PR: https://github.com/appcelerator/titanium_mobile/pull/7722 Demo:
       
       Ti.WatchSession.activateSession();
       
       Ti.API.warn("activationState: " + Ti.WatchSession.activationState);
       Ti.API.warn(Ti.WatchSession.ACTIVATION_STATE_NOT_ACTIVATED); // 0
       Ti.API.warn(Ti.WatchSession.ACTIVATION_STATE_INACTIVE); // 1
       Ti.API.warn(Ti.WatchSession.ACTIVATION_STATE_ACTIVATED); // 2
       
       Ti.WatchSession.addEventListener("inactive", function(e) {
       	Ti.API.warn("Watch became inactive");
       	Ti.API.warn(e);
       });
       
       Ti.WatchSession.addEventListener("deactivate", function(e) {
       	Ti.API.warn("Watch was deactivated");
       	Ti.API.warn(e);
       });
       
       Ti.WatchSession.addEventListener("activationCompleted", function(e) {
       	Ti.API.warn("Watch activation completed");
       	Ti.API.warn(e);
       });
       
  2. Chee Kiat Ng 2016-03-06

    I tried to FR this but, it doesn't seem to work, and it gets stuck at:
       [TRACE] [ioslib] Waiting for Watch App to install...
       
    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*
  3. Hans Knöchel 2016-03-06

    This is weird..Are you sure it is related to the PR and works without? Will re-validate tomorrow.
  4. Hans Knöchel 2016-03-08

  5. Chris Barber 2016-03-08

    [~hansknoechel] TIMOB-20489 should not affect this.
  6. Fokke Zandbergen 2016-03-21

    [~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}
  7. Hans Knöchel 2016-03-21

    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.
  8. Fokke Zandbergen 2016-03-22

    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.
  9. Chee Kiat Ng 2016-04-07

  10. Harry Bryant 2016-08-08

    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.*

JSON Source