diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..e14d6a3e6 --- /dev/null +++ b/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + "react-native", + "react-native-stage-0" + ] +} diff --git a/ios/app/watchos/app/Base.lproj/Interface.storyboard b/ios/app/watchos/app/Base.lproj/Interface.storyboard index 0f0f677d9..485997460 100644 --- a/ios/app/watchos/app/Base.lproj/Interface.storyboard +++ b/ios/app/watchos/app/Base.lproj/Interface.storyboard @@ -15,6 +15,11 @@ diff --git a/ios/app/watchos/extension/ExtensionDelegate.swift b/ios/app/watchos/extension/ExtensionDelegate.swift index d25ffc208..dda52aae8 100644 --- a/ios/app/watchos/extension/ExtensionDelegate.swift +++ b/ios/app/watchos/extension/ExtensionDelegate.swift @@ -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)") + } } diff --git a/ios/app/watchos/extension/InterfaceController.swift b/ios/app/watchos/extension/InterfaceController.swift index fe581a199..4f6b6b9a9 100644 --- a/ios/app/watchos/extension/InterfaceController.swift +++ b/ios/app/watchos/extension/InterfaceController.swift @@ -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) diff --git a/package.json b/package.json index cf1f24182..514b41679 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/react/features/app/components/App.native.js b/react/features/app/components/App.native.js index 4dd9101cf..f1c755a00 100644 --- a/react/features/app/components/App.native.js +++ b/react/features/app/components/App.native.js @@ -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'; diff --git a/react/features/mobile/watchos/middleware.js b/react/features/mobile/watchos/middleware.js index a42cfc4a8..8eecef79c 100644 --- a/react/features/mobile/watchos/middleware.js +++ b/react/features/mobile/watchos/middleware.js @@ -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: