Skip to content

Commit

Permalink
Merge pull request #8061 from hansemannn/TIMOB-23513
Browse files Browse the repository at this point in the history
[TIMOB-23513] iOS10: Support new WatchConnectivity APIs
  • Loading branch information
hansemannn committed Jul 18, 2016
2 parents e31eb5e + 05ccb25 commit 20297ed
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
31 changes: 31 additions & 0 deletions apidoc/Titanium/WatchSession/WatchSession.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ properties:
platforms: [iphone]
since: "5.4.0"

- name: hasContentPending
summary: Returns `true` if there is more content for the session to deliver.
type: Boolean
permission: read-only
osver: {ios: {min: "10.0"}}
since: "6.0.0"
platforms: [iphone]

- name: remainingComplicationUserInfoTransfers
summary: |
The number of calls remaining to `transferCurrentComplication` before the system starts
transferring the complicationUserInfo as regular userInfos.
type: Number
permission: read-only
osver: {ios: {min: "10.0"}}
since: "6.0.0"
default: 0
platforms: [iphone]

- name: isSupported
summary: Returns `true` if the device supports watch connectivity.
type: Boolean
Expand Down Expand Up @@ -423,6 +442,18 @@ events:
and later. See <Ti.WatchSession.isActivated> for more infos.
type: Boolean
platforms: [iphone]
- name: hasContentPending
summary: |
If the apple watch has currently content pending. Only available on iOS 10.0
and later. See <Ti.WatchSession.hasContentPending> for more infos.
type: Boolean
platforms: [iphone]
- name: remainingComplicationUserInfoTransfers
summary: |
If the apple watch has complication userInfo transfers left. Only available on iOS 10.0
and later. See <Ti.WatchSession.remainingComplicationUserInfoTransfers> for more infos.
type: Boolean
platforms: [iphone]
- name: activationState
summary: |
Returns the current activation state of the watch. Only available on iOS 9.3
Expand Down
37 changes: 32 additions & 5 deletions iphone/Classes/WatchSessionModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ -(NSNumber*)isPaired
if ([WCSession isSupported] == YES) {
return NUMBOOL([[self watchSession] isPaired]);
}
DebugLog(@"[ERROR] Target does not support watch connectivity");

return NUMBOOL(NO);
}

Expand All @@ -104,7 +104,7 @@ -(NSNumber*)isWatchAppInstalled
if ([WCSession isSupported] == YES) {
return NUMBOOL([[self watchSession] isWatchAppInstalled]);
}
DebugLog(@"[ERROR] Target does not support watch connectivity");

return NUMBOOL(NO);
}

Expand All @@ -113,7 +113,7 @@ -(NSNumber*)isComplicationEnabled
if ([WCSession isSupported] == YES) {
return NUMBOOL([[self watchSession] isComplicationEnabled]);
}
DebugLog(@"[ERROR] Target does not support watch connectivity");

return NUMBOOL(NO);
}

Expand All @@ -122,7 +122,7 @@ -(NSNumber*)isReachable
if ([WCSession isSupported] == YES) {
return NUMBOOL([[self watchSession] isReachable]);
}
DebugLog(@"[ERROR] Target does not support watch connectivity");

return NUMBOOL(NO);
}

Expand All @@ -131,11 +131,31 @@ -(NSNumber*)isActivated
if ([TiUtils isIOS9_3OrGreater] && [WCSession isSupported]) {
return NUMBOOL([[self watchSession] activationState] == WCSessionActivationStateActivated);
}
return NUMBOOL(NO);
}

DebugLog(@"[ERROR] Target does not support watch connectivity");
-(NSNumber*)hasContentPending
{
#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater] && [WCSession isSupported]) {
return NUMBOOL([[self watchSession] hasContentPending]);
}
#endif

return NUMBOOL(NO);
}

-(NSNumber*)remainingComplicationUserInfoTransfers
{
#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater] && [WCSession isSupported]) {
return NUMUINTEGER([[self watchSession] remainingComplicationUserInfoTransfers]);
}
#endif

return NUMBOOL(0);
}

-(NSNumber*)activationState
{
if ([TiUtils isIOS9_3OrGreater] && [WCSession isSupported]) {
Expand Down Expand Up @@ -464,6 +484,13 @@ -(NSDictionary*)dictionaryFromWatchSession:(WCSession*)session
[dict setObject:[self activationState] forKey:@"activationState"];
}

#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
[dict setObject:[self hasContentPending] forKey:@"hasContentPending"];
[dict setObject:[self remainingComplicationUserInfoTransfers] forKey:@"remainingComplicationUserInfoTransfers"];
}
#endif

return dict;
}

Expand Down

0 comments on commit 20297ed

Please sign in to comment.