This commit is contained in:
Saúl Ibarra Corretgé 2017-09-27 16:50:55 +02:00
parent 367bc693f7
commit 93aa8c5883
7 changed files with 68 additions and 12 deletions

6
.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": [
"react-native",
"react-native-stage-0"
]
}

View File

@ -15,6 +15,11 @@
<controller id="AgC-eL-Hgc" customClass="InterfaceController" customModule="JitsiMeetCompanion" customModuleProvider="target">
<items>
<label alignment="center" verticalAlignment="center" text="Hello Jitser!" id="fxp-ol-Hnn"/>
<button width="1" alignment="left" verticalAlignment="bottom" title="Test" id="oL4-qG-LPp">
<connections>
<action selector="testClicked" destination="AgC-eL-Hgc" id="xgt-e4-JKG"/>
</connections>
</button>
</items>
</controller>
</objects>

View File

@ -1,17 +1,31 @@
//
// ExtensionDelegate.swift
// JitsiMeetCompanion Extension
//
// Created by Saul Corretge on 9/27/17.
// Copyright © 2017 Facebook. All rights reserved.
//
/*
* Copyright @ 2017-present Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import WatchConnectivity
import WatchKit
class ExtensionDelegate: NSObject, WKExtensionDelegate {
class ExtensionDelegate: NSObject, WCSessionDelegate, WKExtensionDelegate {
func applicationDidFinishLaunching() {
// Perform any final initialization of your application.
// Start Watch Connectivity
if WCSession.isSupported() {
let session = WCSession.default
session.delegate = self
session.activate()
}
}
func applicationDidBecomeActive() {
@ -46,5 +60,14 @@ class ExtensionDelegate: NSObject, WKExtensionDelegate {
}
}
}
func session(_ session: WCSession, activationDidCompleteWith
activationState: WCSessionActivationState, error: Error?) {
if let error = error {
print("WC Session activation failed with error: \(error.localizedDescription)")
return
}
print("WC Session activated with state: \(activationState.rawValue)")
}
}

View File

@ -6,12 +6,19 @@
// Copyright © 2017 Facebook. All rights reserved.
//
import WatchConnectivity
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBAction func testClicked() {
if WCSession.isSupported() {
let session = WCSession.default
session.sendMessage(["conference": "https://meet.jit.si/WatchyMcWatchFace"], replyHandler: nil, errorHandler: nil)
}
}
override func awake(withContext context: Any?) {
super.awake(withContext: context)

View File

@ -84,6 +84,8 @@
"babel-polyfill": "6.26.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"babel-preset-react-native": "4.0.0",
"babel-preset-react-native-stage-0": "1.0.1",
"babel-preset-stage-1": "6.24.1",
"clean-css": "3.4.25",
"css-loader": "0.28.5",

View File

@ -13,6 +13,8 @@ import '../../mobile/full-screen';
import '../../mobile/permissions';
import '../../mobile/proximity';
import '../../mobile/wake-lock';
import '../../mobile/watchos';
import { AbstractApp } from './AbstractApp';

View File

@ -3,7 +3,7 @@
import { Platform } from 'react-native';
import * as watch from 'react-native-watch-connectivity';
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../app';
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT, appNavigate } from '../../app';
import {
CONFERENCE_FAILED,
CONFERENCE_LEFT,
@ -20,7 +20,7 @@ import { MiddlewareRegistry } from '../../base/redux';
* @param {Store} store - The redux store.
* @returns {Function}
*/
MiddlewareRegistry.register(({ getState }) => next => action => {
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const result = next(action);
if (Platform.OS !== 'ios') {
@ -36,6 +36,17 @@ MiddlewareRegistry.register(({ getState }) => next => action => {
console.log('ERROR getting watchState');
}
});
watch.subscribeToMessages((err, message, reply) => {
if (!err) {
if (message.conference) {
dispatch(appNavigate(message.conference));
}
//reply({text: "message received!"});
} else {
console.log('ERROR getting watch message');
}
});
break;
}
case APP_WILL_UNMOUNT: