@daily-co/react-native-daily-js 0.58.0 → 0.59.0

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 CHANGED
@@ -15,7 +15,7 @@ Install `react-native-daily-js` along with its peer dependencies:
15
15
 
16
16
  ```bash
17
17
  npm i @daily-co/react-native-daily-js @react-native-async-storage/async-storage@^1.15.7 react-native-background-timer@^2.3.1 react-native-get-random-values@^1.9.0
18
- npm i --save-exact @daily-co/react-native-webrtc@111.0.0-daily.2
18
+ npm i --save-exact @daily-co/react-native-webrtc@118.0.3-daily.1
19
19
  ```
20
20
 
21
21
  Then, follow the below steps to set up your native project on each platform. **Note that these steps assume you're using a version of React Native that supports autolinking (>= 60).**
@@ -93,15 +93,20 @@ Add the following to `AndroidManifest.xml`:
93
93
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
94
94
  <uses-permission android:name="android.permission.WAKE_LOCK" />
95
95
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
96
+
96
97
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
98
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA"/>
99
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
100
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>
101
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
97
102
 
98
103
  <application>
99
104
  // ...
100
- <service android:name="com.daily.reactlibrary.DailyOngoingMeetingForegroundService" android:foregroundServiceType="mediaProjection"/>
105
+ <service android:name="com.daily.reactlibrary.DailyOngoingMeetingForegroundService" android:foregroundServiceType="camera|microphone"/>
101
106
  </application>
102
107
  ```
103
108
 
104
- > Note: above, `foregroundServiceType` is only needed if you wish to do screen sharing.
109
+ > Note: above, `android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION` is only needed if you wish to do screen sharing.
105
110
 
106
111
  Update your `minSdkVersion` in your top-level `build.gradle` file:
107
112
 
@@ -1,7 +1,7 @@
1
- def DEFAULT_COMPILE_SDK_VERSION = 31
2
- def DEFAULT_BUILD_TOOLS_VERSION = '31.0.0'
1
+ def DEFAULT_COMPILE_SDK_VERSION = 34
2
+ def DEFAULT_BUILD_TOOLS_VERSION = '34.0.0'
3
3
  def DEFAULT_MIN_SDK_VERSION = 24
4
- def DEFAULT_TARGET_SDK_VERSION = 31
4
+ def DEFAULT_TARGET_SDK_VERSION = 34
5
5
 
6
6
  def safeExtGet(prop, fallback) {
7
7
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -26,7 +26,7 @@ buildscript {
26
26
  }
27
27
 
28
28
  android {
29
- compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
29
+ compileSdk safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
30
30
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
31
31
  defaultConfig {
32
32
  minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
@@ -1,26 +1,48 @@
1
1
  package com.daily.reactlibrary;
2
2
 
3
+ import android.Manifest;
3
4
  import android.app.Activity;
5
+ import android.content.Intent;
6
+ import android.content.pm.PackageManager;
7
+ import android.os.Build;
4
8
  import android.os.Process;
5
9
  import android.view.Window;
6
10
  import android.view.WindowManager;
7
11
 
12
+ import androidx.core.app.ActivityCompat;
13
+ import androidx.core.content.ContextCompat;
14
+ import androidx.fragment.app.FragmentActivity;
15
+
16
+ import com.facebook.react.bridge.Arguments;
17
+ import com.facebook.react.bridge.BaseActivityEventListener;
8
18
  import com.facebook.react.bridge.LifecycleEventListener;
9
19
  import com.facebook.react.bridge.ReactApplicationContext;
10
20
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
11
21
  import com.facebook.react.bridge.ReactMethod;
22
+ import com.facebook.react.bridge.WritableMap;
23
+ import com.facebook.react.modules.core.PermissionAwareActivity;
24
+ import com.facebook.react.modules.core.PermissionListener;
12
25
 
26
+ import java.util.ArrayList;
27
+ import java.util.Arrays;
13
28
  import java.util.HashSet;
29
+ import java.util.List;
14
30
  import java.util.Set;
15
31
 
16
- public class DailyNativeUtils extends ReactContextBaseJavaModule {
32
+ public class DailyNativeUtils extends ReactContextBaseJavaModule implements PermissionListener {
17
33
 
18
34
  private static final String TAG = DailyNativeUtils.class.getName();
35
+ private static int PERMISSION_REQUEST_CODE = 666;
19
36
 
20
37
  private final ReactApplicationContext reactContext;
21
38
  private Set<String> requestersKeepingDeviceAwake = new HashSet<>();
22
39
  private Set<String> requestersShowingOngoingMeetingNotification = new HashSet<>();
23
40
 
41
+ // Info's received to crete the notification
42
+ private String title;
43
+ private String subtitle;
44
+ private String iconName;
45
+
24
46
  public DailyNativeUtils(ReactApplicationContext reactContext) {
25
47
  super(reactContext);
26
48
  this.reactContext = reactContext;
@@ -74,7 +96,10 @@ public class DailyNativeUtils extends ReactContextBaseJavaModule {
74
96
  } else {
75
97
  requestersShowingOngoingMeetingNotification.remove(requesterId);
76
98
  }
77
- updateOngoingMeetingForegroundService(activity, title, subtitle, iconName);
99
+ this.title = title;
100
+ this.subtitle = subtitle;
101
+ this.iconName = iconName;
102
+ updateOngoingMeetingForegroundService();
78
103
  });
79
104
  }
80
105
  }
@@ -88,9 +113,57 @@ public class DailyNativeUtils extends ReactContextBaseJavaModule {
88
113
  }
89
114
  }
90
115
 
91
- private void updateOngoingMeetingForegroundService(Activity activity, String title, String subtitle, String iconName) {
92
- if (requestersShowingOngoingMeetingNotification.size() > 0) {
93
- DailyOngoingMeetingForegroundService.start(activity.getClass(), title, subtitle, iconName, reactContext);
116
+ @Override
117
+ public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
118
+ if (requestCode == PERMISSION_REQUEST_CODE &&
119
+ Arrays.stream(grantResults).allMatch(result -> result == PackageManager.PERMISSION_GRANTED)) {
120
+ this.initializeOngoingMeetingForegroundService();
121
+ } else {
122
+ System.err.println("Failed to grant permissions.");
123
+ }
124
+ return true;
125
+ }
126
+
127
+ private void checkPermissions() {
128
+ List<String> permissionList = new ArrayList<String>();
129
+ permissionList.add(Manifest.permission.CAMERA);
130
+ permissionList.add(Manifest.permission.RECORD_AUDIO);
131
+ if (Build.VERSION.SDK_INT >= 33) {
132
+ permissionList.add(Manifest.permission.POST_NOTIFICATIONS);
133
+ }
134
+
135
+ boolean allPermissionsGranted = true;
136
+ for (String permission : permissionList) {
137
+ if (ContextCompat.checkSelfPermission(this.reactContext.getApplicationContext(), permission) != PackageManager.PERMISSION_GRANTED) {
138
+ allPermissionsGranted = false;
139
+ break;
140
+ }
141
+ }
142
+
143
+ if (!allPermissionsGranted) {
144
+ Activity currentActivity = this.reactContext.getCurrentActivity();
145
+ if (currentActivity instanceof PermissionAwareActivity) {
146
+ PermissionAwareActivity permissionAware = (PermissionAwareActivity) currentActivity;
147
+ permissionAware.requestPermissions(permissionList.toArray(new String[0]), PERMISSION_REQUEST_CODE, this);
148
+ }
149
+ } else {
150
+ // Permissions are already granted, we can initialize
151
+ initializeOngoingMeetingForegroundService();
152
+ }
153
+ }
154
+
155
+ private void initializeOngoingMeetingForegroundService(){
156
+ Activity activity = getCurrentActivity();
157
+ if (activity != null) {
158
+ activity.runOnUiThread(() -> {
159
+ DailyOngoingMeetingForegroundService.start(activity.getClass(), title, subtitle, iconName, reactContext);
160
+ });
161
+ }
162
+ }
163
+
164
+ private void updateOngoingMeetingForegroundService() {
165
+ if (!requestersShowingOngoingMeetingNotification.isEmpty()) {
166
+ this.checkPermissions();
94
167
  } else {
95
168
  DailyOngoingMeetingForegroundService.stop(reactContext);
96
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daily-co/react-native-daily-js",
3
- "version": "0.58.0",
3
+ "version": "0.59.0",
4
4
  "description": "React Native library for making video calls using Daily",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,20 +28,20 @@
28
28
  "baseUrl": "https://github.com/daily-co/react-native-daily-js"
29
29
  },
30
30
  "dependencies": {
31
- "@daily-co/daily-js": "^0.60.0",
31
+ "@daily-co/daily-js": "^0.61.1",
32
32
  "@types/react-native-background-timer": "^2.0.0",
33
33
  "base-64": "^1.0.0",
34
34
  "react-native-url-polyfill": "^1.1.2"
35
35
  },
36
36
  "///": "WHEN ONE OF THESE CHANGE, PLEASE UPDATE README.md INSTALL SNIPPET ACCORDINGLY",
37
37
  "peerDependencies": {
38
- "@daily-co/react-native-webrtc": "^111.0.0-daily.2",
38
+ "@daily-co/react-native-webrtc": "^118.0.3-daily.1",
39
39
  "@react-native-async-storage/async-storage": "^1.15.7",
40
40
  "react-native-background-timer": "^2.3.1",
41
41
  "react-native-get-random-values": "^1.9.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@daily-co/react-native-webrtc": "^111.0.0-daily.2",
44
+ "@daily-co/react-native-webrtc": "^118.0.3-daily.1",
45
45
  "@react-native-async-storage/async-storage": "^1.15.7",
46
46
  "@types/base-64": "^1.0.0",
47
47
  "react-native-background-timer": "^2.3.1",
@@ -1424,15 +1424,15 @@ export interface DailyCall {
1424
1424
  geo(): Promise<{ current: string }>;
1425
1425
  on<T extends DailyEvent>(
1426
1426
  event: T,
1427
- handler: (event?: DailyEventObject<T>) => void
1427
+ handler: (event: DailyEventObject<T>) => void
1428
1428
  ): DailyCall;
1429
1429
  once<T extends DailyEvent>(
1430
1430
  event: T,
1431
- handler: (event?: DailyEventObject<T>) => void
1431
+ handler: (event: DailyEventObject<T>) => void
1432
1432
  ): DailyCall;
1433
1433
  off<T extends DailyEvent>(
1434
1434
  event: T,
1435
- handler: (event?: DailyEventObject<T>) => void
1435
+ handler: (event: DailyEventObject<T>) => void
1436
1436
  ): DailyCall;
1437
1437
  properties: {
1438
1438
  dailyConfig?: DailyAdvancedConfig;