Skip to content

Commit 3ad2c6b

Browse files
committed
Introduce checkPhoneAccountEnabled and isConnectionServiceAvailable
1 parent 698f795 commit 3ad2c6b

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,21 @@ public void openPhoneAccountSettings() {
432432
this.getAppContext().startActivity(intent);
433433
}
434434

435-
@ReactMethod
436435
public static Boolean isConnectionServiceAvailable() {
437436
// PhoneAccount is available since api level 23
438437
return Build.VERSION.SDK_INT >= 23;
439438
}
440439

440+
@ReactMethod
441+
public void isConnectionServiceAvailable(Promise promise) {
442+
promise.resolve(isConnectionServiceAvailable());
443+
}
444+
445+
@ReactMethod
446+
public void checkPhoneAccountEnabled(Promise promise) {
447+
promise.resolve(hasPhoneAccount());
448+
}
449+
441450
@ReactMethod
442451
public void backToForeground() {
443452
Context context = getAppContext();

index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ declare module 'react-native-callkeep' {
7777
handle: string,
7878
): void
7979

80+
static checkPhoneAccountEnabled(): Promise<boolean>;
81+
82+
static isConnectionServiceAvailable(): Promise<boolean>;
83+
8084
/**
8185
* @description reportConnectedOutgoingCallWithUUID method is available only on iOS.
8286
*/

index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ class RNCallKeep {
101101
RNCallKeepModule.startCall(uuid, handle, contactIdentifier, handleType, hasVideo);
102102
};
103103

104+
checkPhoneAccountEnabled = async () => {
105+
if (isIOS) {
106+
return;
107+
}
108+
109+
return RNCallKeepModule.checkPhoneAccountEnabled();
110+
}
111+
112+
isConnectionServiceAvailable = async () => {
113+
if (isIOS) {
114+
return true;
115+
}
116+
117+
return RNCallKeepModule.isConnectionServiceAvailable();
118+
}
119+
104120
reportConnectingOutgoingCallWithUUID = (uuid) => {
105121
//only available on iOS
106122
if (isIOS) {

0 commit comments

Comments
 (0)