diff --git a/android/build.gradle b/android/build.gradle index 07e88d0c..fe2c8ef2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,7 +1,7 @@ buildscript { repositories { - jcenter() google() + jcenter() } dependencies { diff --git a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java index 1466545d..b4c8073a 100644 --- a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java +++ b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java @@ -49,7 +49,7 @@ // @see https://github.com/kbagchiGWC/voice-quickstart-android/blob/9a2aff7fbe0d0a5ae9457b48e9ad408740dfb968/exampleConnectionService/src/main/java/com/twilio/voice/examples/connectionservice/VoiceConnectionServiceActivity.java public class RNCallKeepModule extends ReactContextBaseJavaModule { - public static final int REQUEST_READ_PHONE_STATE = 394858; + public static final int REQUEST_READ_PHONE_STATE = 1337; public static final int REQUEST_REGISTER_CALL_PROVIDER = 394859; public static final String CHECKING_PERMS = "CHECKING_PERMS"; @@ -228,6 +228,18 @@ public static Boolean isConnectionServiceAvailable() { return Build.VERSION.SDK_INT >= 23; } + @ReactMethod + public void backToForeground() { + Context context = getAppContext(); + String packageName = context.getApplicationContext().getPackageName(); + Intent focusIntent = context.getPackageManager().getLaunchIntentForPackage(packageName).cloneFilter(); + + focusIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + + Activity activity = getCurrentActivity(); + activity.startActivity(focusIntent); + } + private void registerPhoneAccount(Context appContext) { if (!isConnectionServiceAvailable()) { return; diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..955662e7 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,136 @@ +export type Events = 'didReceiveStartCallAction' | + 'answerCall' | + 'endCall' | + 'didActivateAudioSession' | + 'didDisplayIncomingCall' | + 'didPerformSetMutedCallAction'; + +type HandleType = 'generic' | 'number' | 'email'; + +interface IOptions { + ios: { + appName: string, + imageName?: string, + ringtoneSound?: string, + }, + android: { + alertTitle: string, + alertDescription: string, + cancelButton: string, + okButton: string, + }, +} + +export type DidReceiveStartCallActionPayload = { handle: string }; +export type AnswerCallPayload = { callUUID: string }; +export type EndCallPayload = AnswerCallPayload; +export type DidDisplayIncomingCallPayload = string | undefined; +export type DidPerformSetMutedCallActionPayload = boolean; + +export default class RNCallKeep { + static addEventListener(type: Events, handler: (args: any) => void) { + + } + + static removeEventListener(type: Events, handler: (args: any) => void) { + + } + + static async setup(options: IOptions): Promise { + + } + + static displayIncomingCall( + uuid: string, + handle: string, + localizedCallerName?: string, + handleType?: HandleType, + hasVideo?: boolean, + ) { + + } + + /** + * @description startCall method is available only on iOS. + */ + static startCall( + uuid: string, + handle: string, + handleType?: HandleType, + hasVideo: boolean, + contactIdentifier?: string, + ) { + + } + + /** + * @description reportConnectedOutgoingCallWithUUID method is available only on iOS. + */ + static reportConnectedOutgoingCallWithUUID(uuid: string) { + + } + + static endCall(uuid: string) { + + } + + static endAllCalls() { + + } + + /** + * @description supportConnectionService method is available only on Android. + */ + static supportConnectionService(): boolean { + + } + + /** + * @description hasPhoneAccount method is available only on Android. + */ + static async hasPhoneAccount(): Promise { + + } + + /** + * @description setMutedCall method is available only on iOS. + */ + static setMutedCall(uuid: string, muted: boolean) { + + } + + /** + * @description setMutedCall method is available only on iOS. + */ + static checkIfBusy(): Promise { + + } + + /** + * @description setMutedCall method is available only on iOS. + */ + static checkSpeaker(): Promise { + + } + + /** + * @description setAvailable method is available only on Android. + */ + static setAvailable(active: boolean) { + + } + + /** + * @description setAvailable method is available only on Android. + */ + static setCurrentCallActive() { + + } + + /** + * @description setAvailable method is available only on Android. + */ + static backToForeground() { + + } +} \ No newline at end of file diff --git a/index.js b/index.js index 18a88a3c..18d88809 100644 --- a/index.js +++ b/index.js @@ -148,6 +148,14 @@ class RNCallKeep { }); }; + backToForeground() { + if (isIOS) { + return; + } + + NativeModules.RNCallKeep.backToForeground(); + } + /* static holdCall(uuid, onHold) { RNCallKeepModule.setHeldCall(uuid, onHold); diff --git a/package.json b/package.json index 2877d226..c013eaaf 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "url": "https://github.com/wazo-pbx/react-native-callkeep/issues" }, "homepage": "https://github.com/wazo-pbx/react-native-callkeep#readme", + "typings": "./index.d.ts", "peerDependencies": { "react-native": ">=0.40.0" },