|
1 |
| -# ApiRTC-ionic |
2 |
| -Webrtc sample with ionic |
| 1 | +# ApiRTC on Ionic |
| 2 | +This tutorial explains you how to use apiRTC and to build an application for iOS. |
| 3 | + |
| 4 | +First of all you need to install Ionic. Please follow [this link](http://ionicframework.com/getting-started/) to get started with ionic |
| 5 | + |
| 6 | +To build this example, you first need to add a target platform and a few plugins |
| 7 | +``` |
| 8 | +git clone https://github.com/apizee/ApiRTC-ionic.git |
| 9 | +cd ApiRTC-ionic |
| 10 | +npm install xcode |
| 11 | +ionic build |
| 12 | +ionic cordova platform remove ios |
| 13 | +chmod +x plugins/cordova-plugin-iosrtc/extra/hooks/iosrtc-swift-support.js |
| 14 | +ionic cordova platform add ios |
| 15 | +``` |
| 16 | + |
| 17 | +Then, run an emulator like this : |
| 18 | +``` |
| 19 | +ionic cordova build ios |
| 20 | +ionic cordova run ios |
| 21 | +
|
| 22 | +``` |
| 23 | + |
| 24 | +Open [this link](https://apirtc.com/tutos/Mobile/index.html) with Chrome to exchange with your mobile over webrtc |
| 25 | + |
| 26 | +## Requirements |
| 27 | + |
| 28 | +In order to make this application run into a iOS application some requirements must be satisfied in both development computer and target devices: |
| 29 | + |
| 30 | +* Xcode >= 7.2.1 |
| 31 | +* iOS >= 9 (run on lower versions at your own risk, but don't report issues) |
| 32 | +* `cordova-ios` 4.X |
| 33 | + |
| 34 | +## ApiRTC key |
| 35 | +For this demo we use the Api key "myDemoApiKey". Please register on [our website](https://apirtc.com/get-key/) to get your private api key. |
| 36 | + |
| 37 | +## Building errors on iOS |
| 38 | +To avoid errors, we use the plugin cordova-custom-config to integrate all Xcode configuration. But you can find solutions here: |
| 39 | + |
| 40 | +**Build error** |
| 41 | + |
| 42 | +Swift is unavailable on iOS versions under 7.0. Please set IPHONEOS_DEPLOYMENT_TARGET to 7.0 or later (currently it is ‘6.0’). |
| 43 | + |
| 44 | +**Solution** |
| 45 | + |
| 46 | +Click on your project files tree in XCode on HelloCordova |
| 47 | +Go to Build Settings, look under Deployment Info, change iOS Deployment Target to 7.0 |
| 48 | + |
| 49 | + |
| 50 | +**Build error** |
| 51 | + |
| 52 | +"Use of undeclared identifier” and “Use of undeclared type" |
| 53 | + |
| 54 | +**Solution** |
| 55 | + |
| 56 | +Go to Build Settings, look under “Swift Compiler – Code Generation” (near the bottom), edit the setting “Objective-C Bridging Header” and enter ../../plugins/cordova-plugin-iosrtc/src/cordova-plugin-iosrtc-Bridging-Header.h in debug and release |
| 57 | + |
| 58 | + |
| 59 | +**Build error** |
| 60 | + |
| 61 | +You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) |
| 62 | + |
| 63 | +**Solution** |
| 64 | + |
| 65 | +Go to Build Settings, Build Option, edit the setting “Enable bitcode” to “NO” |
| 66 | + |
| 67 | + |
| 68 | +**Runtime error** |
| 69 | + |
| 70 | +Thread 1: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)” Meanwhile, the output console shows: dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /private/var/mobile/Containers/Bundle/Application/XX/WebRTCSample.app/WebRTCSample Reason: image not found |
| 71 | + |
| 72 | +**Solution** |
| 73 | + |
| 74 | +Go to Build Settings, look under Linking, edit “Runpath Search Paths”, and add the path @executable_path/Frameworks in debug and release |
| 75 | + |
| 76 | +##Building errors on Android |
| 77 | +**Add the following permissions to the Android manifest **:(<nameOfYourProject>/platforms/android/AndroidManifest.xml). |
| 78 | +<uses-permission android:name=”android.permission.RECORD_AUDIO” /> |
| 79 | +<uses-permission android:name=”android.permission.CAMERA” /> |
| 80 | +<uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” /> |
| 81 | + |
| 82 | +##Optional tips |
| 83 | + |
| 84 | +The crosswalk plugin is not necessary for Android 5.0+ as WebRTC is now supported in native WebView. It may enable you to have lightweight application but you will loose compatibility with Android version less than 5.0 |
| 85 | + |
| 86 | +The following steps will convert the project to use Android 5.0+ native WebView. |
| 87 | + |
| 88 | +-If crosswalk plugin is already added, remove it with Terminal command : |
| 89 | +cordova plugin remove cordova-plugin-crosswalk-webview |
| 90 | +-In AndroidManifest.xml, set the minSdkVersion to 21. |
| 91 | +-A patch may be needed in Cordova to allow WebRTC getUserMedia. Refer to pull request https://github.com/apache/cordova-android/pull/178/files to make changes to the file /platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java. |
| 92 | + |
| 93 | +##Try your project |
| 94 | + |
| 95 | +In order to test, open [this link](https://cloud.apizee.com/apiRTC/Samples/apiPhone-level2.html) on your computer browser: |
| 96 | + |
| 97 | +You will be able to establish a webRTC call between your app and your computer using the number that has been automatically assigned to your apiRTC Client. |
0 commit comments