@kapsula-chat/capacitor-push-calls 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Package.swift
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import PackageDescription
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
|
-
name: "
|
|
5
|
+
name: "KapsulaChatCapacitorPushCalls",
|
|
6
6
|
platforms: [.iOS(.v13)],
|
|
7
7
|
products: [
|
|
8
8
|
.library(
|
|
9
|
-
name: "
|
|
9
|
+
name: "KapsulaChatCapacitorPushCalls",
|
|
10
10
|
targets: ["CapacitorPushCallsPlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
package/android/build.gradle
CHANGED
|
@@ -39,7 +39,7 @@ dependencies {
|
|
|
39
39
|
implementation project(':capacitor-android')
|
|
40
40
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
41
41
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
|
42
|
-
|
|
42
|
+
implementation "com.google.firebase:firebase-messaging:24.1.2"
|
|
43
43
|
testImplementation "junit:junit:$junitVersion"
|
|
44
44
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
45
45
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -54,6 +54,8 @@ class CapacitorVoipCallsPlugin : Plugin() {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
internal fun getInstance(): CapacitorVoipCallsPlugin? = pluginInstance
|
|
58
|
+
|
|
57
59
|
fun routeRemoteMessage(context: Context, data: Map<String, String>, title: String?, body: String?) {
|
|
58
60
|
val type = data["type"]?.lowercase()
|
|
59
61
|
if (type == "call") {
|
|
@@ -124,6 +126,19 @@ class CapacitorVoipCallsPlugin : Plugin() {
|
|
|
124
126
|
|
|
125
127
|
@PluginMethod
|
|
126
128
|
fun register(call: PluginCall) {
|
|
129
|
+
val firebaseReady = try {
|
|
130
|
+
FirebaseApp.getApps(context).isNotEmpty() || FirebaseApp.initializeApp(context) != null
|
|
131
|
+
} catch (_: IllegalStateException) {
|
|
132
|
+
false
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!firebaseReady) {
|
|
136
|
+
val message = "Firebase is not initialized. Add google-services.json or initialize FirebaseApp before register()."
|
|
137
|
+
emitEvent("registrationError", JSObject().apply { put("error", message) })
|
|
138
|
+
call.reject(message)
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
FirebaseMessaging.getInstance().token
|
|
128
143
|
.addOnSuccessListener { token ->
|
|
129
144
|
emitEvent("registration", JSObject().apply { put("value", token) })
|
|
@@ -374,7 +389,7 @@ class CapacitorVoipCallsPlugin : Plugin() {
|
|
|
374
389
|
val handleType = call.getString("handleType") ?: "generic"
|
|
375
390
|
val video = call.getBoolean("video", false) ?: false
|
|
376
391
|
|
|
377
|
-
if (!
|
|
392
|
+
if (!hasAudioPermission()) {
|
|
378
393
|
if (!canRequestPermissions) {
|
|
379
394
|
call.reject("Missing required RECORD_AUDIO permission")
|
|
380
395
|
return
|
|
@@ -425,7 +440,7 @@ class CapacitorVoipCallsPlugin : Plugin() {
|
|
|
425
440
|
return
|
|
426
441
|
}
|
|
427
442
|
|
|
428
|
-
if (!
|
|
443
|
+
if (!hasAudioPermission()) {
|
|
429
444
|
if (!canRequestPermissions) {
|
|
430
445
|
call.reject("Missing required RECORD_AUDIO permission")
|
|
431
446
|
return
|
|
@@ -562,7 +577,7 @@ class CapacitorVoipCallsPlugin : Plugin() {
|
|
|
562
577
|
emitEvent("pushNotificationActionPerformed", actionPayload)
|
|
563
578
|
}
|
|
564
579
|
|
|
565
|
-
private fun
|
|
580
|
+
private fun hasAudioPermission(): Boolean {
|
|
566
581
|
return ContextCompat.checkSelfPermission(
|
|
567
582
|
context,
|
|
568
583
|
Manifest.permission.RECORD_AUDIO
|
|
@@ -6,7 +6,6 @@ import android.telecom.Connection
|
|
|
6
6
|
import android.telecom.DisconnectCause
|
|
7
7
|
import android.telecom.VideoProfile
|
|
8
8
|
import androidx.annotation.RequiresApi
|
|
9
|
-
import com.getcapacitor.Bridge
|
|
10
9
|
|
|
11
10
|
@RequiresApi(Build.VERSION_CODES.M)
|
|
12
11
|
class VoipConnection(
|
|
@@ -31,14 +30,10 @@ class VoipConnection(
|
|
|
31
30
|
if (video) {
|
|
32
31
|
setVideoState(VideoProfile.STATE_BIDIRECTIONAL)
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (plugin is CapacitorVoipCallsPlugin) {
|
|
39
|
-
callManager = plugin.callManager
|
|
40
|
-
callManager?.registerConnection(callId, this)
|
|
41
|
-
}
|
|
33
|
+
// Use the live plugin instance when available to hook events/call state.
|
|
34
|
+
CapacitorVoipCallsPlugin.getInstance()?.let { plugin ->
|
|
35
|
+
callManager = plugin.callManager
|
|
36
|
+
callManager?.registerConnection(callId, this)
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
39
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kapsula-chat/capacitor-push-calls",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Capacitor plugin with push routing (message/call), CallKit (iOS), and ConnectionService (Android)",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|