react-native link react-native-callkeep
-
In
android/app/build.gradle
Add a linecompile project(':react-native-callkeep')
independencies {}
section. -
In
android/settings.gradle
Add:
include ':react-native-callkeep'
project(':react-native-callkeep').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-callkeep/android')
- In
android/app/src/main/java/.../MainApplication.java
:
import io.wazo.callkeep.RNCallKeepPackage; // Add this import line with others
//...
private static List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNCallKeepPackage() // Add this line
);
}
- Add permissionResult listener in
MainActivity.java
:
import io.wazo.callkeep.RNCallKeepModule; // Add this import line with others
public class MainActivity extends ReactActivity {
// ...
// Permission results
@Override
public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(permsRequestCode, permissions, grantResults);
switch (permsRequestCode) {
case RNCallKeepModule.REQUEST_READ_PHONE_STATE:
RNCallKeepModule.onRequestPermissionsResult(grantResults);
break;
}
}
}
- In
android/app/src/main/AndroidManifest.xml
add these permissions:
<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application>
// ...
<service android:name="io.wazo.callkeep.VoiceConnectionService"
android:label="Wazo"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>
// ....
</application>