Skip to content

Commit 0af789f

Browse files
authored
Update README
For linking Obj-C project and some nit-picking on words
1 parent 80aeeb3 commit 0af789f

File tree

1 file changed

+64
-72
lines changed

1 file changed

+64
-72
lines changed

README.md

Lines changed: 64 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
Handling media-routes/sensors/events during a audio/video chat on React Native
88

99
## Purpose:
10+
1011
The purpose of this module is to handle actions/events during a phone call (audio/video) on `react-native`, ex:
11-
* manage devices events like wired-headset plugged in state, proximity sensors and expose functionalities to javascript.
12-
* automatically route audio to proper devices based on events and platform API.
13-
* toggle speaker or microphone on/off, toggle flash light on/off
14-
* play ringtone/ringback/dtmftone
1512

16-
basically, it is a telecommunication module which handles most of requirements when making/receiving/talking with a call.
13+
* Manage devices events like wired-headset plugged in state, proximity sensors and expose functionalities to javascript.
14+
* Automatically route audio to proper devices based on events and platform API.
15+
* Toggle speaker or microphone on/off, toggle flash light on/off
16+
* Play ringtone/ringback/dtmftone
17+
18+
Basically, it is a telecommunication module which handles most of requirements when making/receiving/talking with a call.
1719

1820
This module is desinged to work with [react-native-webrtc](https://github.com/oney/react-native-webrtc)
1921
you can find demo here: https://github.com/oney/RCTWebRTCDemo
@@ -23,41 +25,40 @@ you can find demo here: https://github.com/oney/RCTWebRTCDemo
2325

2426
#### BREAKING NOTE:
2527

26-
* since `2.1.0`, you should use `RN 40+` and upgrade your xcode to support `swift 3`.
28+
* Since `2.1.0`, you should use `RN 40+` and upgrade your xcode to support `swift 3`.
2729
after upgrading xcode, `Edit -> Convert -> To Current Swift Syntax` to invoke `Swift Migration Assistant`
2830
see [Migrating to Swift 2.3 or Swift 3 from Swift 2.2](https://swift.org/migration-guide/)
2931

30-
* for old RN versions (RN < 0.40) please use version `1.5.4` ( Swift 2.2~2.3 )
32+
* For old RN versions (RN < 0.40) please use version `1.5.4` ( Swift 2.2~2.3 )
3133

3234

33-
**from npm package**: `npm install react-native-incall-manager`
34-
**from git package**: `npm install git://github.com/zxcpoiu/react-native-incall-manager.git`
35+
**From npm package**: `npm install react-native-incall-manager`
36+
**From git package**: `npm install git://github.com/zxcpoiu/react-native-incall-manager.git`
3537

3638
===================================================
37-
### android:
39+
### Android:
3840

3941
After install, you can use `rnpm` (`npm install rnpm -g`) to link android.
40-
use `rnpm link react-native-incall-manager` to link or manually if you like.
42+
use `react-native link react-native-incall-manager` to link or manually if you like.
4143

4244
We use android support library v4 to check/request permissions.
4345
You should add `compile "com.android.support:support-v4:23.0.1"` in `$your_project/android/app/build.gradle` dependencies on android.
4446

45-
#### Manually Link
47+
#### Manually Linking
4648

47-
if rnpm link doesn't work. ( see: https://github.com/zxcpoiu/react-native-incall-manager/issues/21#issuecomment-279575516 )
48-
please add it manually in your main project:
49+
If `react-native link` doesn't work, ( see: https://github.com/zxcpoiu/react-native-incall-manager/issues/21#issuecomment-279575516 ) please add it manually in your main project:
4950

50-
1. in `android/app/build.gradle`
51-
should have a line `compile(project(':react-native-incall-manager'))` in `dependencies {}` section
51+
1. In `android/app/build.gradle`
52+
Should have a line `compile(project(':react-native-incall-manager'))` in `dependencies {}` section
5253

53-
2. in `android/settings.gradle`
54-
should have:
54+
2. In `android/settings.gradle`
55+
Should have:
5556
```
5657
include ':react-native-incall-manager'
5758
project(':react-native-incall-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-incall-manager/android')
5859
```
5960
60-
3. in `MainApplication.java`
61+
3. In `MainApplication.java`
6162
6263
```java
6364
import com.zxcpoiu.incallmanager.InCallManagerPackage;
@@ -69,9 +70,9 @@ project(':react-native-incall-manager').projectDir = new File(rootProject.projec
6970
);
7071
}
7172
```
72-
#### optional sound files on android
73+
#### Optional sound files on android
7374
74-
if you want to use bundled ringtone/ringback/busytone sound instead of system sound,
75+
If you want to use bundled ringtone/ringback/busytone sound instead of system sound,
7576
put files in `android/app/src/main/res/raw`
7677
and rename file correspond to sound type:
7778
@@ -81,61 +82,52 @@ incallmanager_ringback.mp3
8182
incallmanager_ringtone.mp3
8283
```
8384
84-
on android, as long as your file extension supported by android, this module will load it.
85+
On android, as long as your file extension supported by android, this module will load it.
8586
8687
===================================================
8788
8889
### ios:
8990
90-
since ios part written in swift and it doesn't support static library yet.
91-
before that, you should add this project manually
92-
please do it step by step carefully :pray: :
91+
`react-native link react-native-incall-manager`
9392
94-
#### Add files in to your project:
93+
#### Manually Linking
9594
96-
1. Open your project in xcode
97-
2. find your_project directory under your project's xcodeproject root. ( it's a sub-directoory, not root xcodeproject itself )
98-
3. you can do either:
99-
(recommended) directly drag your node_modules/react-native-incall-manager/ios/RNInCallManager/ into it.
100-
(may have some [path issue](https://github.com/zxcpoiu/react-native-incall-manager/issues/39)) right click on your_project directory, `add files` to your project and add `node_modules/react-native-incall-manager/ios/RNInCallManager/`
101-
4. on the pou-up window, uncheck `Copy items if needed` and select `Added folders: Create groups` then add it. you will see a new directory named `RNInCallmanager under your_project` directory.
102-
103-
#### Setup Objective-C Bridging Header:
104-
1. click your `project's xcodeproject root`, go to `build setting` and search `Objective-C Bridging Header`
105-
2. set you header location, the default path is: `ReactNativeProjectRoot/ios/`,
106-
in this case, you should set `../node_modules/react-native-incall-manager/ios/RNInCallManager/RNInCallManager-Bridging-Header.h`
107-
108-
### Swift:
109-
Make sure you set swift version to `3.2`: ![swift](https://i.imgur.com/lYubEVt.png)
95+
In case `react-native link` doesn't work,
11096
97+
- Drag `node_modules/react-native-incall-manager/ios/RNInCallManager.xcodeproj` under `<your_xcode_project>/Libraries`
98+
- Select `<your_xcode_project>` --> `Build Phases` --> `Link Binary With Libraries`
99+
- Drag `Libraries/RNInCallManager.xcodeproj/Products/libRNInCallManager.a` to `Link Binary With Libraries`
100+
- Select `<your_xcode_project>` --> `Build Settings`
101+
- In `Header Search Paths`, add `$(SRCROOT)/../node_modules/react-native-incall-manager/ios/RNInCallManager`
111102
112103
#### Clean project if messed up:
104+
113105
The installation steps are a bit complex, it might related your xcode version, xcode cache, converting swift version, and your own path configurations. if something messed up, please folow steps below to clean this project, then do it again steps by steps.
114106
115-
1. delete all project/directory in xcode related to incall-manager
116-
2. delete `react-native-incall-manager` in node_modules ( rm -rf )
107+
1. Delete all project/directory in xcode related to incall-manager
108+
2. Delete `react-native-incall-manager` in node_modules ( rm -rf )
117109
3. Xcode -> Product -> clean
118-
4. close xcode
119-
5. npm install again
120-
6. open xcode and try the install process again steps by steps
110+
4. Close xcode
111+
5. Run `npm install` again
112+
6. Open xcode and try the install process again steps by steps
121113
122-
if someone knows a simpler way to set this project up, let me know plz.
114+
If someone knows a simpler way to set this project up, let me know plz.
123115
124-
#### optional sound files on android
116+
#### Optional sound files on iOS
125117
126-
if you want to use bundled ringtone/ringback/busytone sound instead of system sound
118+
If you want to use bundled ringtone/ringback/busytone sound instead of system sound
127119
128-
1. add files into your_project directory under your project's xcodeproject root. ( or drag into it as described above. )
129-
2. check `copy file if needed`
130-
3. make sure filename correspond to sound type:
120+
1. Add files into your_project directory under your project's xcodeproject root. ( or drag into it as described above. )
121+
2. Check `copy file if needed`
122+
3. Make sure filename correspond to sound type:
131123
132124
```
133125
incallmanager_busytone.mp3
134126
incallmanager_ringback.mp3
135127
incallmanager_ringtone.mp3
136128
```
137129
138-
on ios, we only support mp3 files currently.
130+
On ios, we only support mp3 files currently.
139131
140132
## Usage:
141133
@@ -155,7 +147,7 @@ InCallManager.stop();
155147
// ... it will also remote event listeners ...
156148
```
157149

158-
if you want to use ringback:
150+
If you want to use ringback:
159151

160152
```javascript
161153
// ringback is basically for OUTGOING call. and is part of start().
@@ -165,7 +157,7 @@ InCallManager.start({media: 'audio', ringback: '_BUNDLE_'}); // or _DEFAULT_ or
165157
InCallManager.stopRingback();
166158
```
167159

168-
if you want to use busytone:
160+
If you want to use busytone:
169161

170162
```javascript
171163
// busytone is basically for OUTGOING call. and is part of stop()
@@ -174,7 +166,7 @@ if you want to use busytone:
174166
InCallManager.stop({busytone: '_DTMF_'}); // or _BUNDLE_ or _DEFAULT_
175167
```
176168

177-
if you want to use ringtone:
169+
If you want to use ringtone:
178170

179171
```javascript
180172
// ringtone is basically for INCOMING call. it's independent to start() and stop()
@@ -192,8 +184,8 @@ InCallManager.stop();
192184

193185
```
194186

195-
also can interact with events if you want:
196-
see API section.
187+
Also can interact with events if you want:
188+
See API section.
197189

198190
```javascript
199191
import { DeviceEventEmitter } from 'react-native';
@@ -207,7 +199,7 @@ DeviceEventEmitter.addListener('Proximity', function (data) {
207199
## About Permission:
208200

209201

210-
since version 1.2.0, two functions and a property were added:
202+
Since version 1.2.0, two functions and a property were added:
211203

212204
```javascript
213205
// --- function
@@ -255,7 +247,7 @@ Step 2: override `onRequestPermissionsResult` in your `MainActivity.java` like:
255247
}
256248
```
257249

258-
then you can test it on android 6 now.
250+
Then you can test it on android 6 now.
259251

260252
**Another thing you should know is:**
261253

@@ -264,29 +256,29 @@ So in **development mode**, you should manually grant permission in `app setting
264256
You don't have to do this in **release mode** since there are no red box.
265257

266258

267-
checkout this awesome project: [react-native-android-permissions](https://github.com/lucasferreira/react-native-android-permissions) by @lucasferreira for more information.
259+
Checkout this awesome project: [react-native-android-permissions](https://github.com/lucasferreira/react-native-android-permissions) by @lucasferreira for more information.
268260

269261

270262
## Automatic Basic Behavior:
271263

272-
**on start:**
273-
* store current settings, set KeepScreenOn flag = true, and register some event listeners.
274-
* if media type is `audio`, route voice to earpiece, otherwise route to speaker.
275-
* audio will enable proximity sensor which is disabled by default if media=video
276-
* when proximity detect user closed to screen, turn off screen to avoid accident touch and route voice to earpiece.
277-
* when newly external device plugged, such as wired-headset, route audio to external device.
278-
* optional play ringback
264+
**On start:**
265+
* Store current settings, set KeepScreenOn flag = true, and register some event listeners.
266+
* If media type is `audio`, route voice to earpiece, otherwise route to speaker.
267+
* Audio will enable proximity sensor which is disabled by default if media=video
268+
* When proximity detect user closed to screen, turn off screen to avoid accident touch and route voice to earpiece.
269+
* When newly external device plugged, such as wired-headset, route audio to external device.
270+
* Optional play ringback
279271

280-
**on stop:**
272+
**On stop:**
281273

282-
* set KeepScreenOn flag = false, remote event listeners, restore original user settings.
283-
* optional play busytone
274+
* Set KeepScreenOn flag = false, remote event listeners, restore original user settings.
275+
* Optional play busytone
284276

285277
## Custom Behavior:
286278

287-
you can custom behavior use API/events exposed by this module. see `API` section.
279+
You can custom behavior use API/events exposed by this module. see `API` section.
288280

289-
note: ios only supports `auto` currently.
281+
Note: ios only supports `auto` currently.
290282

291283
## API:
292284

0 commit comments

Comments
 (0)