@capgo/capacitor-stream-call 0.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.
Files changed (39) hide show
  1. package/Package.swift +31 -0
  2. package/README.md +340 -0
  3. package/StreamCall.podspec +19 -0
  4. package/android/build.gradle +74 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/ee/forgr/capacitor/streamcall/CallOverlayView.kt +281 -0
  7. package/android/src/main/java/ee/forgr/capacitor/streamcall/CustomNotificationHandler.kt +142 -0
  8. package/android/src/main/java/ee/forgr/capacitor/streamcall/IncomingCallView.kt +147 -0
  9. package/android/src/main/java/ee/forgr/capacitor/streamcall/RingtonePlayer.kt +164 -0
  10. package/android/src/main/java/ee/forgr/capacitor/streamcall/StreamCallPlugin.kt +1014 -0
  11. package/android/src/main/java/ee/forgr/capacitor/streamcall/TouchInterceptWrapper.kt +31 -0
  12. package/android/src/main/java/ee/forgr/capacitor/streamcall/UserRepository.kt +111 -0
  13. package/android/src/main/res/.gitkeep +0 -0
  14. package/android/src/main/res/values/strings.xml +7 -0
  15. package/dist/docs.json +533 -0
  16. package/dist/esm/definitions.d.ts +169 -0
  17. package/dist/esm/definitions.js +2 -0
  18. package/dist/esm/definitions.js.map +1 -0
  19. package/dist/esm/index.d.ts +4 -0
  20. package/dist/esm/index.js +7 -0
  21. package/dist/esm/index.js.map +1 -0
  22. package/dist/esm/web.d.ts +32 -0
  23. package/dist/esm/web.js +323 -0
  24. package/dist/esm/web.js.map +1 -0
  25. package/dist/plugin.cjs.js +337 -0
  26. package/dist/plugin.cjs.js.map +1 -0
  27. package/dist/plugin.js +339 -0
  28. package/dist/plugin.js.map +1 -0
  29. package/ios/Sources/StreamCallPlugin/CallOverlayView.swift +147 -0
  30. package/ios/Sources/StreamCallPlugin/CustomCallParticipantImageView.swift +60 -0
  31. package/ios/Sources/StreamCallPlugin/CustomCallView.swift +257 -0
  32. package/ios/Sources/StreamCallPlugin/CustomVideoParticipantsView.swift +107 -0
  33. package/ios/Sources/StreamCallPlugin/ParticipantsView.swift +206 -0
  34. package/ios/Sources/StreamCallPlugin/StreamCallPlugin.swift +722 -0
  35. package/ios/Sources/StreamCallPlugin/TouchInterceptView.swift +177 -0
  36. package/ios/Sources/StreamCallPlugin/UserRepository.swift +96 -0
  37. package/ios/Sources/StreamCallPlugin/WebviewNavigationDelegate.swift +68 -0
  38. package/ios/Tests/StreamCallPluginTests/StreamCallPluginTests.swift +15 -0
  39. package/package.json +96 -0
package/Package.swift ADDED
@@ -0,0 +1,31 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "StreamCall",
6
+ platforms: [.iOS(.v14)],
7
+ products: [
8
+ .library(
9
+ name: "StreamCall",
10
+ targets: ["StreamCallPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0"),
14
+ .package(url: "https://github.com/GetStream/stream-video-swift.git", exact: "1.16.0")
15
+ ],
16
+ targets: [
17
+ .target(
18
+ name: "StreamCallPlugin",
19
+ dependencies: [
20
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
21
+ .product(name: "Cordova", package: "capacitor-swift-pm"),
22
+ .product(name: "StreamVideo", package: "stream-video-swift"),
23
+ .product(name: "StreamVideoSwiftUI", package: "stream-video-swift")
24
+ ],
25
+ path: "ios/Sources/StreamCallPlugin"),
26
+ .testTarget(
27
+ name: "StreamCallPluginTests",
28
+ dependencies: ["StreamCallPlugin"],
29
+ path: "ios/Tests/StreamCallPluginTests")
30
+ ]
31
+ )
package/README.md ADDED
@@ -0,0 +1,340 @@
1
+ # stream-call
2
+ <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
+
4
+ <div align="center">
5
+ <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo 🚀</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin"> Fix your annoying bug now, Hire a Capacitor expert 💪</a></h2>
7
+ </div>
8
+
9
+ WIP: We are actively working on this plugin. not yet ready for production.
10
+ Uses the https://getstream.io/ SDK to implement calling in Capacitor
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install stream-call
16
+ npx cap sync
17
+ ```
18
+
19
+ ## Setting up Android StreamVideo apikey
20
+ 1. Add your apikey to the Android project:
21
+ ```
22
+ your_app/android/app/src/main/res/values/strings.xml
23
+ ```
24
+
25
+ 2. Add your apikey to the Android project:
26
+ ```xml
27
+ <string name="CAPACITOR_STREAM_VIDEO_APIKEY">your_api_key</string>
28
+ ```
29
+
30
+ ## Setting up iOS StreamVideo apikey
31
+ 1. Add your apikey to the iOS project:
32
+ ```
33
+ your_app/ios/App/App/Info.plist
34
+ ```
35
+
36
+ Add the following to the Info.plist file:
37
+ ```xml
38
+ <dict>
39
+ <key>CAPACITOR_STREAM_VIDEO_APIKEY</key>
40
+ <string>n8wv8vjmucdw</string>
41
+ <!-- other keys -->
42
+ </dict>
43
+ ```
44
+
45
+ ## Native Localization
46
+
47
+ ### iOS
48
+
49
+ 1. Add `Localizable.strings` and `Localizable.stringsdict` files to your Xcode project if you don't have them:
50
+ ```
51
+ /App/App/en.lproj/Localizable.strings
52
+ /App/App/en.lproj/Localizable.stringsdict
53
+ ```
54
+
55
+ 2. Add new languages to your project in Xcode:
56
+ - Open project settings
57
+ - Select your project
58
+ - Click "Info" tab
59
+ - Under "Localizations" click "+"
60
+ - Select the languages you want to add
61
+
62
+ 3. Add the translations in your `Localizable.strings`:
63
+ ```
64
+ // en.lproj/Localizable.strings
65
+ "stream.video.call.incoming" = "Incoming call from %@";
66
+ "stream.video.call.accept" = "Accept";
67
+ "stream.video.call.reject" = "Reject";
68
+ "stream.video.call.hangup" = "Hang up";
69
+ "stream.video.call.joining" = "Joining...";
70
+ "stream.video.call.reconnecting" = "Reconnecting...";
71
+ ```
72
+
73
+ 4. Configure the localization provider in your `AppDelegate.swift`:
74
+ ```swift
75
+ import StreamVideo
76
+
77
+ @UIApplicationMain
78
+ class AppDelegate: UIResponder, UIApplicationDelegate {
79
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
80
+ // Set localization provider to use your app's bundle
81
+ Appearance.localizationProvider = { key, table in
82
+ Bundle.main.localizedString(forKey: key, value: nil, table: table)
83
+ }
84
+ return true
85
+ }
86
+ }
87
+ ```
88
+
89
+ You can find all available localization keys in the [StreamVideo SDK repository](https://github.com/GetStream/stream-video-swift/blob/main/Sources/StreamVideoSwiftUI/Resources/en.lproj/Localizable.strings).
90
+
91
+ ### Android
92
+ 1. Create string resources in `/app/src/main/res/values/strings.xml`:
93
+ ```xml
94
+ <?xml version="1.0" encoding="utf-8"?>
95
+ <resources>
96
+ <string name="stream_video_call_incoming">Incoming call from %1$s</string>
97
+ <string name="stream_video_call_accept">Accept</string>
98
+ <string name="stream_video_call_reject">Reject</string>
99
+ <string name="stream_video_call_hangup">Hang up</string>
100
+ <string name="stream_video_call_joining">Joining...</string>
101
+ <string name="stream_video_call_reconnecting">Reconnecting...</string>
102
+ </resources>
103
+ ```
104
+
105
+ 2. Add translations for other languages in their respective folders (e.g., `/app/src/main/res/values-fr/strings.xml`):
106
+ ```xml
107
+ <?xml version="1.0" encoding="utf-8"?>
108
+ <resources>
109
+ <string name="stream_video_call_incoming">Appel entrant de %1$s</string>
110
+ <string name="stream_video_call_accept">Accepter</string>
111
+ <string name="stream_video_call_reject">Refuser</string>
112
+ <string name="stream_video_call_hangup">Raccrocher</string>
113
+ <string name="stream_video_call_joining">Connexion...</string>
114
+ <string name="stream_video_call_reconnecting">Reconnexion...</string>
115
+ </resources>
116
+ ```
117
+
118
+ The SDK will automatically use the system language and these translations.
119
+
120
+ ## API
121
+
122
+ <docgen-index>
123
+
124
+ * [`login(...)`](#login)
125
+ * [`logout()`](#logout)
126
+ * [`call(...)`](#call)
127
+ * [`endCall()`](#endcall)
128
+ * [`setMicrophoneEnabled(...)`](#setmicrophoneenabled)
129
+ * [`setCameraEnabled(...)`](#setcameraenabled)
130
+ * [`addListener('callEvent', ...)`](#addlistenercallevent-)
131
+ * [`removeAllListeners()`](#removealllisteners)
132
+ * [`acceptCall()`](#acceptcall)
133
+ * [`rejectCall()`](#rejectcall)
134
+ * [Interfaces](#interfaces)
135
+ * [Type Aliases](#type-aliases)
136
+
137
+ </docgen-index>
138
+
139
+ <docgen-api>
140
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
141
+
142
+ ### login(...)
143
+
144
+ ```typescript
145
+ login(options: LoginOptions) => Promise<SuccessResponse>
146
+ ```
147
+
148
+ Login to Stream Video service
149
+
150
+ | Param | Type | Description |
151
+ | ------------- | ----------------------------------------------------- | --------------------- |
152
+ | **`options`** | <code><a href="#loginoptions">LoginOptions</a></code> | - Login configuration |
153
+
154
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
155
+
156
+ --------------------
157
+
158
+
159
+ ### logout()
160
+
161
+ ```typescript
162
+ logout() => Promise<SuccessResponse>
163
+ ```
164
+
165
+ Logout from Stream Video service
166
+
167
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
168
+
169
+ --------------------
170
+
171
+
172
+ ### call(...)
173
+
174
+ ```typescript
175
+ call(options: CallOptions) => Promise<SuccessResponse>
176
+ ```
177
+
178
+ Initiate a call to another user
179
+
180
+ | Param | Type | Description |
181
+ | ------------- | --------------------------------------------------- | -------------------- |
182
+ | **`options`** | <code><a href="#calloptions">CallOptions</a></code> | - Call configuration |
183
+
184
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
185
+
186
+ --------------------
187
+
188
+
189
+ ### endCall()
190
+
191
+ ```typescript
192
+ endCall() => Promise<SuccessResponse>
193
+ ```
194
+
195
+ End the current call
196
+
197
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
198
+
199
+ --------------------
200
+
201
+
202
+ ### setMicrophoneEnabled(...)
203
+
204
+ ```typescript
205
+ setMicrophoneEnabled(options: { enabled: boolean; }) => Promise<SuccessResponse>
206
+ ```
207
+
208
+ Enable or disable microphone
209
+
210
+ | Param | Type | Description |
211
+ | ------------- | ---------------------------------- | ------------------ |
212
+ | **`options`** | <code>{ enabled: boolean; }</code> | - Microphone state |
213
+
214
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
215
+
216
+ --------------------
217
+
218
+
219
+ ### setCameraEnabled(...)
220
+
221
+ ```typescript
222
+ setCameraEnabled(options: { enabled: boolean; }) => Promise<SuccessResponse>
223
+ ```
224
+
225
+ Enable or disable camera
226
+
227
+ | Param | Type | Description |
228
+ | ------------- | ---------------------------------- | -------------- |
229
+ | **`options`** | <code>{ enabled: boolean; }</code> | - Camera state |
230
+
231
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
232
+
233
+ --------------------
234
+
235
+
236
+ ### addListener('callEvent', ...)
237
+
238
+ ```typescript
239
+ addListener(eventName: 'callEvent', listenerFunc: (event: CallEvent) => void) => Promise<{ remove: () => Promise<void>; }>
240
+ ```
241
+
242
+ Add listener for call events
243
+
244
+ | Param | Type | Description |
245
+ | ------------------ | ------------------------------------------------------------------- | --------------------------------- |
246
+ | **`eventName`** | <code>'callEvent'</code> | - Name of the event to listen for |
247
+ | **`listenerFunc`** | <code>(event: <a href="#callevent">CallEvent</a>) =&gt; void</code> | - Callback function |
248
+
249
+ **Returns:** <code>Promise&lt;{ remove: () =&gt; Promise&lt;void&gt;; }&gt;</code>
250
+
251
+ --------------------
252
+
253
+
254
+ ### removeAllListeners()
255
+
256
+ ```typescript
257
+ removeAllListeners() => Promise<void>
258
+ ```
259
+
260
+ Remove all event listeners
261
+
262
+ --------------------
263
+
264
+
265
+ ### acceptCall()
266
+
267
+ ```typescript
268
+ acceptCall() => Promise<SuccessResponse>
269
+ ```
270
+
271
+ Accept an incoming call
272
+
273
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
274
+
275
+ --------------------
276
+
277
+
278
+ ### rejectCall()
279
+
280
+ ```typescript
281
+ rejectCall() => Promise<SuccessResponse>
282
+ ```
283
+
284
+ Reject an incoming call
285
+
286
+ **Returns:** <code>Promise&lt;<a href="#successresponse">SuccessResponse</a>&gt;</code>
287
+
288
+ --------------------
289
+
290
+
291
+ ### Interfaces
292
+
293
+
294
+ #### SuccessResponse
295
+
296
+ | Prop | Type | Description |
297
+ | ------------- | -------------------- | ------------------------------------ |
298
+ | **`success`** | <code>boolean</code> | Whether the operation was successful |
299
+
300
+
301
+ #### LoginOptions
302
+
303
+ | Prop | Type | Description |
304
+ | ------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
305
+ | **`token`** | <code>string</code> | Stream Video API token |
306
+ | **`userId`** | <code>string</code> | User ID for the current user |
307
+ | **`name`** | <code>string</code> | Display name for the current user |
308
+ | **`imageURL`** | <code>string</code> | Optional avatar URL for the current user |
309
+ | **`apiKey`** | <code>string</code> | Stream Video API key |
310
+ | **`magicDivId`** | <code>string</code> | ID of the HTML element where the video will be rendered |
311
+ | **`refreshToken`** | <code>{ url: string; headers?: <a href="#record">Record</a>&lt;string, string&gt;; }</code> | Configuration for token refresh |
312
+
313
+
314
+ #### CallOptions
315
+
316
+ | Prop | Type | Description |
317
+ | ------------ | -------------------- | ------------------------------------------------ |
318
+ | **`userId`** | <code>string</code> | User ID of the person to call |
319
+ | **`type`** | <code>string</code> | Type of call, defaults to 'default' |
320
+ | **`ring`** | <code>boolean</code> | Whether to ring the other user, defaults to true |
321
+
322
+
323
+ #### CallEvent
324
+
325
+ | Prop | Type | Description |
326
+ | ------------ | ------------------- | ------------------------- |
327
+ | **`callId`** | <code>string</code> | ID of the call |
328
+ | **`state`** | <code>string</code> | Current state of the call |
329
+
330
+
331
+ ### Type Aliases
332
+
333
+
334
+ #### Record
335
+
336
+ Construct a type with a set of properties K of type T
337
+
338
+ <code>{
339
  [P in K]: T;
1
340
  }</code>
341
+
342
+ </docgen-api>
@@ -0,0 +1,19 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'StreamCall'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '14.0'
15
+ s.dependency 'Capacitor'
16
+ s.dependency 'StreamVideo'
17
+ s.dependency 'StreamVideoSwiftUI'
18
+ s.swift_version = '5.1'
19
+ end
@@ -0,0 +1,74 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
6
+ kotlin_version = '2.1.10'
7
+ }
8
+
9
+ buildscript {
10
+ repositories {
11
+ google()
12
+ mavenCentral()
13
+ }
14
+ dependencies {
15
+ classpath 'com.android.tools.build:gradle:8.7.2'
16
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.10"
17
+ classpath 'org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:2.1.10'
18
+ }
19
+ }
20
+
21
+ apply plugin: 'com.android.library'
22
+ apply plugin: 'org.jetbrains.kotlin.android'
23
+ apply plugin: 'org.jetbrains.kotlin.plugin.compose'
24
+
25
+ android {
26
+ namespace "ee.forgr.capacitor.streamcall"
27
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
28
+ defaultConfig {
29
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
30
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
31
+ versionCode 1
32
+ versionName "1.0"
33
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
34
+ }
35
+ buildTypes {
36
+ release {
37
+ minifyEnabled false
38
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
39
+ }
40
+ }
41
+ lintOptions {
42
+ abortOnError false
43
+ }
44
+ compileOptions {
45
+ sourceCompatibility JavaVersion.VERSION_21
46
+ targetCompatibility JavaVersion.VERSION_21
47
+ }
48
+ kotlinOptions {
49
+ jvmTarget = '21'
50
+ }
51
+ buildFeatures {
52
+ compose = true
53
+ }
54
+ }
55
+
56
+ repositories {
57
+ google()
58
+ mavenCentral()
59
+ }
60
+
61
+ // ab
62
+ dependencies {
63
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
64
+ implementation project(':capacitor-android')
65
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
66
+ implementation 'androidx.core:core-ktx:1.15.0'
67
+ implementation 'androidx.compose.material3:material3'
68
+ implementation("io.getstream:stream-video-android-ui-compose:1.3.1")
69
+ implementation "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
70
+ implementation("io.getstream:stream-android-push-firebase:1.3.0")
71
+ testImplementation "junit:junit:$junitVersion"
72
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
73
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
74
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>