voip-callkit 0.0.1
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/README.md +154 -0
- package/VoipCallkit.podspec +17 -0
- package/android/build.gradle +58 -0
- package/android/src/main/.DS_Store +0 -0
- package/android/src/main/AndroidManifest.xml +55 -0
- package/android/src/main/java/.DS_Store +0 -0
- package/android/src/main/java/com/.DS_Store +0 -0
- package/android/src/main/java/com/test/.DS_Store +0 -0
- package/android/src/main/java/com/test/callkit/.DS_Store +0 -0
- package/android/src/main/java/com/test/callkit/CallKitVoip.java +12 -0
- package/android/src/main/java/com/test/callkit/CallKitVoipPlugin.java +81 -0
- package/android/src/main/java/com/test/callkit/MyConnectionService.java +200 -0
- package/android/src/main/java/com/test/callkit/MyFirebaseMessagingService.java +90 -0
- package/android/src/main/java/com/test/callkit/androidcall/ApiCalls.java +48 -0
- package/android/src/main/java/com/test/callkit/androidcall/CallActivity.java +1223 -0
- package/android/src/main/java/com/test/callkit/androidcall/RetreivedTokenCallback.java +5 -0
- package/android/src/main/java/com/test/callkit/androidcall/SettingsActivity.java +174 -0
- package/android/src/main/java/com/test/callkit/androidcall/VoipBackgroundService.java +103 -0
- package/android/src/main/java/com/test/callkit/androidcall/VoipForegroundService.java +210 -0
- package/android/src/main/java/com/test/callkit/androidcall/VoipForegroundServiceActionReceiver.java +77 -0
- package/android/src/main/java/com/test/callkit/androidcall/util/CameraCapturerCompat.java +185 -0
- package/android/src/main/java/com/test/callkit/androidcall/util/CodecUtils.kt +23 -0
- package/android/src/main/java/com/test/callkit/androidcall/util/Dialog.java +37 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +262 -0
- package/dist/esm/definitions.d.ts +19 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +8 -0
- package/dist/esm/web.js +11 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +27 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +30 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CallKitVoip.swift +1 -0
- package/ios/Plugin/CallKitVoipPlugin.h +10 -0
- package/ios/Plugin/CallKitVoipPlugin.m +8 -0
- package/ios/Plugin/CallKitVoipPlugin.swift +129 -0
- package/ios/Plugin/Info.plist +24 -0
- package/package.json +78 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
import Foundation
|
2
|
+
import Capacitor
|
3
|
+
import UIKit
|
4
|
+
import CallKit
|
5
|
+
import PushKit
|
6
|
+
|
7
|
+
/**
|
8
|
+
* CallKit Voip Plugin provides native PushKit functionality with apple CallKit to ionic capacitor
|
9
|
+
*/
|
10
|
+
@objc(CallKitVoipPlugin)
|
11
|
+
public class CallKitVoipPlugin: CAPPlugin {
|
12
|
+
|
13
|
+
private var provider: CXProvider?
|
14
|
+
private let voipRegistry = PKPushRegistry(queue: nil)
|
15
|
+
private var connectionIdRegistry : [UUID: CallConfig] = [:]
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
@objc func register(_ call: CAPPluginCall) {
|
20
|
+
// config PushKit
|
21
|
+
voipRegistry.delegate = self
|
22
|
+
voipRegistry.desiredPushTypes = [.voIP]
|
23
|
+
|
24
|
+
let config = CXProviderConfiguration(localizedName: "Video Call")
|
25
|
+
config.supportsVideo = true
|
26
|
+
config.supportedHandleTypes = [.emailAddress]
|
27
|
+
|
28
|
+
provider = CXProvider(configuration: config)
|
29
|
+
provider?.setDelegate(self, queue: DispatchQueue.main)
|
30
|
+
|
31
|
+
call.resolve()
|
32
|
+
}
|
33
|
+
|
34
|
+
@objc func incomingCall(_ call: CAPPluginCall) {
|
35
|
+
// TODO
|
36
|
+
}
|
37
|
+
|
38
|
+
public func notifyEvent(eventName: String, uuid: UUID){
|
39
|
+
if let config = connectionIdRegistry[uuid] {
|
40
|
+
notifyListeners(eventName, data: [
|
41
|
+
"connectionId": config.connectionId,
|
42
|
+
"username" : config.username
|
43
|
+
])
|
44
|
+
connectionIdRegistry[uuid] = nil
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
public func incommingCall(from: String, connectionId: String) {
|
49
|
+
let update = CXCallUpdate()
|
50
|
+
update.remoteHandle = CXHandle(type: .generic, value: from)
|
51
|
+
update.hasVideo = true
|
52
|
+
update.supportsDTMF = false
|
53
|
+
update.supportsHolding = true
|
54
|
+
update.supportsGrouping = false
|
55
|
+
update.supportsUngrouping = false
|
56
|
+
update.hasVideo = true
|
57
|
+
|
58
|
+
let uuid = UUID()
|
59
|
+
connectionIdRegistry[uuid] = .init(connectionId: connectionId, username: from)
|
60
|
+
self.provider?.reportNewIncomingCall(with: uuid, update: update, completion: { (_) in })
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
public func endCall(uuid: UUID) {
|
67
|
+
let controller = CXCallController()
|
68
|
+
let transaction = CXTransaction(action:
|
69
|
+
CXEndCallAction(call: uuid));controller.request(transaction,completion: { error in })
|
70
|
+
}
|
71
|
+
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
// MARK: CallKit events handler
|
76
|
+
|
77
|
+
extension CallKitVoipPlugin: CXProviderDelegate {
|
78
|
+
|
79
|
+
public func providerDidReset(_ provider: CXProvider) {
|
80
|
+
print("provider did reset")
|
81
|
+
}
|
82
|
+
|
83
|
+
public func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
84
|
+
print("call answered")
|
85
|
+
notifyEvent(eventName: "callAnswered", uuid: action.callUUID)
|
86
|
+
// endCall(uuid: action.callUUID)
|
87
|
+
action.fulfill()
|
88
|
+
}
|
89
|
+
|
90
|
+
public func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
|
91
|
+
action.fulfill()
|
92
|
+
}
|
93
|
+
|
94
|
+
public func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
|
95
|
+
notifyEvent(eventName: "callStarted", uuid: action.callUUID)
|
96
|
+
action.fulfill()
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
// MARK: PushKit events handler
|
101
|
+
extension CallKitVoipPlugin: PKPushRegistryDelegate {
|
102
|
+
|
103
|
+
public func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
|
104
|
+
let parts = pushCredentials.token.map { String(format: "%02.2hhx", $0) }
|
105
|
+
let token = parts.joined()
|
106
|
+
notifyListeners("registration", data: ["token": token])
|
107
|
+
}
|
108
|
+
|
109
|
+
public func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
|
110
|
+
|
111
|
+
// guard let connectionId = payload.dictionaryPayload["ConnectionId"] as? String else {
|
112
|
+
// return
|
113
|
+
// }
|
114
|
+
|
115
|
+
// let username = (payload.dictionaryPayload["Username"] as? String) ?? "Anonymus"
|
116
|
+
|
117
|
+
|
118
|
+
self.incommingCall(from: "username", connectionId: "123")
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
extension CallKitVoipPlugin {
|
125
|
+
struct CallConfig {
|
126
|
+
let connectionId: String
|
127
|
+
let username : String
|
128
|
+
}
|
129
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
7
|
+
<key>CFBundleExecutable</key>
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
9
|
+
<key>CFBundleIdentifier</key>
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
12
|
+
<string>6.0</string>
|
13
|
+
<key>CFBundleName</key>
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
15
|
+
<key>CFBundlePackageType</key>
|
16
|
+
<string>FMWK</string>
|
17
|
+
<key>CFBundleShortVersionString</key>
|
18
|
+
<string>1.0</string>
|
19
|
+
<key>CFBundleVersion</key>
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
21
|
+
<key>NSPrincipalClass</key>
|
22
|
+
<string></string>
|
23
|
+
</dict>
|
24
|
+
</plist>
|
package/package.json
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
{
|
2
|
+
"name": "voip-callkit",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "capacitor plugin for callkit and voip",
|
5
|
+
"main": "dist/plugin.cjs.js",
|
6
|
+
"module": "dist/esm/index.js",
|
7
|
+
"types": "dist/esm/index.d.ts",
|
8
|
+
"unpkg": "dist/plugin.js",
|
9
|
+
"files": [
|
10
|
+
"android/src/main/",
|
11
|
+
"android/build.gradle",
|
12
|
+
"dist/",
|
13
|
+
"ios/Plugin/",
|
14
|
+
"VoipCallkit.podspec"
|
15
|
+
],
|
16
|
+
"author": "",
|
17
|
+
"license": "MIT",
|
18
|
+
"repository": {
|
19
|
+
"type": "git",
|
20
|
+
"url": "git+https://github.com/vamsi3293/voip-callkit.git.git"
|
21
|
+
},
|
22
|
+
"bugs": {
|
23
|
+
"url": "https://github.com/vamsi3293/voip-callkit.git/issues"
|
24
|
+
},
|
25
|
+
"keywords": [
|
26
|
+
"capacitor",
|
27
|
+
"plugin",
|
28
|
+
"native"
|
29
|
+
],
|
30
|
+
"scripts": {
|
31
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
32
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
|
33
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
34
|
+
"verify:web": "npm run build",
|
35
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
36
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
37
|
+
"eslint": "eslint . --ext ts",
|
38
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
39
|
+
"swiftlint": "node-swiftlint",
|
40
|
+
"docgen": "docgen --api CallKitVoipPlugin --output-readme README.md --output-json dist/docs.json",
|
41
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
42
|
+
"clean": "rimraf ./dist",
|
43
|
+
"watch": "tsc --watch",
|
44
|
+
"prepublishOnly": "npm run build"
|
45
|
+
},
|
46
|
+
"devDependencies": {
|
47
|
+
"@capacitor/android": "^3.0.0",
|
48
|
+
"@capacitor/core": "^3.0.0",
|
49
|
+
"@capacitor/docgen": "^0.0.18",
|
50
|
+
"@capacitor/ios": "^3.0.0",
|
51
|
+
"@ionic/eslint-config": "^0.3.0",
|
52
|
+
"@ionic/prettier-config": "^1.0.1",
|
53
|
+
"@ionic/swiftlint-config": "^1.1.2",
|
54
|
+
"eslint": "^7.11.0",
|
55
|
+
"prettier": "~2.2.0",
|
56
|
+
"prettier-plugin-java": "~1.0.0",
|
57
|
+
"rimraf": "^3.0.2",
|
58
|
+
"rollup": "^2.32.0",
|
59
|
+
"swiftlint": "^1.0.1",
|
60
|
+
"typescript": "~4.0.3"
|
61
|
+
},
|
62
|
+
"peerDependencies": {
|
63
|
+
"@capacitor/core": "^3.0.0"
|
64
|
+
},
|
65
|
+
"prettier": "@ionic/prettier-config",
|
66
|
+
"swiftlint": "@ionic/swiftlint-config",
|
67
|
+
"eslintConfig": {
|
68
|
+
"extends": "@ionic/eslint-config/recommended"
|
69
|
+
},
|
70
|
+
"capacitor": {
|
71
|
+
"ios": {
|
72
|
+
"src": "ios"
|
73
|
+
},
|
74
|
+
"android": {
|
75
|
+
"src": "android"
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|