@capgo/capacitor-stream-call 0.0.40 → 0.0.42
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 +117 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,81 @@ npm install @capgo/capacitor-stream-call
|
|
|
15
15
|
npx cap sync
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
## Android Setup
|
|
19
|
+
|
|
20
|
+
### MainActivity.java
|
|
21
|
+
Modify your `MainActivity.java` to handle incoming calls:
|
|
22
|
+
|
|
23
|
+
```java
|
|
24
|
+
@Override
|
|
25
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
26
|
+
// Save initial intent for StreamCallPlugin (handles killed-state notification)
|
|
27
|
+
ee.forgr.capacitor.streamcall.StreamCallPlugin.saveInitialIntent(getIntent());
|
|
28
|
+
|
|
29
|
+
super.onCreate(savedInstanceState);
|
|
30
|
+
|
|
31
|
+
// Ensure the activity is visible over the lock screen when launched via full-screen intent
|
|
32
|
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O_MR1) {
|
|
33
|
+
setShowWhenLocked(true);
|
|
34
|
+
setTurnScreenOn(true);
|
|
35
|
+
} else {
|
|
36
|
+
getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
protected void onNewIntent(Intent intent) {
|
|
42
|
+
super.onNewIntent(intent);
|
|
43
|
+
setIntent(intent);
|
|
44
|
+
String action = intent.getAction();
|
|
45
|
+
if ("io.getstream.video.android.action.ACCEPT_CALL".equals(action)) {
|
|
46
|
+
android.app.KeyguardManager km = (android.app.KeyguardManager) getSystemService(KEYGUARD_SERVICE);
|
|
47
|
+
if (km != null && km.isKeyguardLocked()) {
|
|
48
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
49
|
+
km.requestDismissKeyguard(this, new KeyguardManager.KeyguardDismissCallback() {
|
|
50
|
+
@Override
|
|
51
|
+
public void onDismissSucceeded() {
|
|
52
|
+
forwardAcceptIntent(intent);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
forwardAcceptIntent(intent);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private void forwardAcceptIntent(Intent intent) {
|
|
63
|
+
ee.forgr.capacitor.streamcall.StreamCallPlugin.saveInitialIntent(intent);
|
|
64
|
+
PluginHandle pluginHandle = getBridge().getPlugin("StreamCall");
|
|
65
|
+
if (pluginHandle != null) {
|
|
66
|
+
com.getcapacitor.Plugin pluginInstance = pluginHandle.getInstance();
|
|
67
|
+
if (pluginInstance instanceof ee.forgr.capacitor.streamcall.StreamCallPlugin) {
|
|
68
|
+
((ee.forgr.capacitor.streamcall.StreamCallPlugin) pluginInstance).handleAcceptCallIntent(intent);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Application Class
|
|
75
|
+
Create or modify your Application class to pre-initialize the plugin:
|
|
76
|
+
|
|
77
|
+
```java
|
|
78
|
+
@Override
|
|
79
|
+
public void onCreate() {
|
|
80
|
+
super.onCreate();
|
|
81
|
+
|
|
82
|
+
// Initialize Firebase
|
|
83
|
+
com.google.firebase.FirebaseApp.initializeApp(this);
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
StreamCallPlugin.preLoadInit(this, this);
|
|
87
|
+
} catch (Exception e) {
|
|
88
|
+
Log.e("App", "Failed to pre-initialize StreamVideo Plugin", e);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
18
93
|
## Setting up Android StreamVideo apikey
|
|
19
94
|
1. Add your apikey to the Android project:
|
|
20
95
|
```
|
|
@@ -160,6 +235,48 @@ This is the only way we found to allow the app to use the same UI when phone is
|
|
|
160
235
|
This can be done that way only on Android on IOS this part is handle by the OS.
|
|
161
236
|
|
|
162
237
|
|
|
238
|
+
Also, for Android you need to change your main activity like so:
|
|
239
|
+
```java
|
|
240
|
+
@Override
|
|
241
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
242
|
+
// Ensure the activity is visible over the lock screen when launched via full-screen intent
|
|
243
|
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O_MR1) {
|
|
244
|
+
setShowWhenLocked(true);
|
|
245
|
+
setTurnScreenOn(true);
|
|
246
|
+
} else {
|
|
247
|
+
getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Furthermore, you need to edit your Application class like so:
|
|
253
|
+
```java
|
|
254
|
+
import ee.forgr.capacitor.streamcall.StreamCallPlugin;
|
|
255
|
+
|
|
256
|
+
@Override
|
|
257
|
+
public void onCreate() {
|
|
258
|
+
super.onCreate();
|
|
259
|
+
initializeApp();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private void initializeApp() {
|
|
263
|
+
Log.i(TAG, "Initializing application...");
|
|
264
|
+
// Initialize Firebase
|
|
265
|
+
com.google.firebase.FirebaseApp.initializeApp(this);
|
|
266
|
+
try {
|
|
267
|
+
StreamCallPlugin.preLoadInit(this, this);
|
|
268
|
+
Log.i(TAG, "StreamVideo Plugin preLoadInit invoked successfully");
|
|
269
|
+
} catch (Exception e) {
|
|
270
|
+
Log.e(TAG, "Failed to pre-initialize StreamVideo Plugin", e);
|
|
271
|
+
}
|
|
272
|
+
Log.i(TAG, "Application initialization completed");
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
> ⚠️ **WARNING**
|
|
277
|
+
>
|
|
278
|
+
> You may not have the Application class in your project, if so you need to create it.
|
|
279
|
+
|
|
163
280
|
## API
|
|
164
281
|
|
|
165
282
|
<docgen-index>
|
package/package.json
CHANGED