rns-nativecall 0.0.2 → 0.0.3

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.
@@ -0,0 +1,53 @@
1
+ buildscript {
2
+ // Check if kotlin version is defined in the root project, otherwise default
3
+ ext.kotlin_version = project.hasProperty('kotlinVersion') ? project.kotlinVersion : '1.8.10'
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.4.2"
12
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13
+ }
14
+ }
15
+
16
+ apply plugin: 'com.android.library'
17
+ apply plugin: 'kotlin-android'
18
+
19
+ // Helper function to find the react-native node_module
20
+ def safeExtGet(prop, fallback) {
21
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
22
+ }
23
+
24
+ android {
25
+ // This MUST match your package name in your .kt files
26
+ namespace "com.rnsnativecall"
27
+ compileSdkVersion safeExtGet('compileSdkVersion', 33)
28
+
29
+ defaultConfig {
30
+ minSdkVersion safeExtGet('minSdkVersion', 21)
31
+ targetSdkVersion safeExtGet('targetSdkVersion', 33)
32
+ }
33
+
34
+ lintOptions {
35
+ abortOnError false
36
+ }
37
+ }
38
+
39
+ repositories {
40
+ mavenCentral()
41
+ google()
42
+ }
43
+
44
+ dependencies {
45
+ // Essential for React Native Native Modules
46
+ implementation "com.facebook.react:react-native:+"
47
+
48
+ // Kotlin Standard Library
49
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
50
+
51
+ // Note: Telecom APIs (ConnectionService) are part of the standard Android SDK,
52
+ // so no extra external dependencies are needed for them.
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Raiidr nativecall component with native Android/iOS for handling native call ui, when app is not open or open.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -3,16 +3,19 @@ require "json"
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = package["name"]
6
+ s.name = "rns-nativecall"
7
7
  s.version = package["version"]
8
- s.summary = package["description"] || "Custom native call for React Native"
9
- s.license = package["license"] || "MIT"
10
- s.author = package["author"] || "Unknown"
11
- s.homepage = package["homepage"] || "https://github.com/your/repo"
12
- s.source = { :git => "https://github.com/raiidr/rns-nativecall.git", :tag => "#{s.version}" }
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+ s.platforms = { :ios => "10.0" }
13
+ s.source = { :git => "https://github.com/your-repo.git", :tag => "#{s.version}" }
13
14
 
14
- s.platforms = { :ios => "11.0" }
15
- s.source_files = "ios/**/*.{h,m}"
15
+ s.source_files = "ios/**/*.{h,m,mm}"
16
+
17
+ # CRITICAL: Tell iOS to include CallKit for the calling UI
18
+ s.frameworks = "CallKit", "AVFoundation"
16
19
 
17
20
  s.dependency "React-Core"
18
- end
21
+ end
package/withRaiidrVoip.js CHANGED
@@ -1,16 +1,24 @@
1
1
  ///Users/bush/Desktop/Apps/Raiidr/package/withRaiidrVoip.js
2
- const { withAndroidManifest, AndroidConfig } = require('@expo/config-plugins');
2
+ const { withAndroidManifest, withInfoPlist, withPlugins } = require('@expo/config-plugins');
3
3
 
4
- function withRaiidrVoip(config) {
4
+ /**
5
+ * ANDROID CONFIGURATION
6
+ */
7
+ function withAndroidConfig(config) {
5
8
  return withAndroidManifest(config, (config) => {
6
9
  const manifest = config.modResults;
7
10
 
8
11
  // 1. Add required permissions
9
12
  const permissions = [
10
13
  'android.permission.READ_PHONE_NUMBERS',
11
- 'android.permission.CALL_PHONE'
14
+ 'android.permission.CALL_PHONE',
15
+ 'android.permission.MANAGE_OWN_CALLS' // Required for Self-Managed ConnectionService
12
16
  ];
13
17
 
18
+ if (!manifest.manifest['uses-permission']) {
19
+ manifest.manifest['uses-permission'] = [];
20
+ }
21
+
14
22
  permissions.forEach((perm) => {
15
23
  if (!manifest.manifest['uses-permission'].some((p) => p.$['android:name'] === perm)) {
16
24
  manifest.manifest['uses-permission'].push({ $: { 'android:name': perm } });
@@ -19,17 +27,17 @@ function withRaiidrVoip(config) {
19
27
 
20
28
  // 2. Add MyConnectionService service
21
29
  const application = manifest.manifest.application[0];
22
- const existingService = application.service?.find(
23
- (s) => s.$['android:name'] === 'com.rnsnativecall.MyConnectionService'
24
- );
30
+ application.service = application.service || [];
31
+
32
+ const serviceName = 'com.rnsnativecall.MyConnectionService';
33
+ const existingService = application.service.find((s) => s.$['android:name'] === serviceName);
25
34
 
26
35
  if (!existingService) {
27
- application.service = application.service || [];
28
36
  application.service.push({
29
37
  $: {
30
- 'android:name': 'com.rnsnativecall.MyConnectionService',
38
+ 'android:name': serviceName,
31
39
  'android:permission': 'android.permission.BIND_CONNECTION_SERVICE',
32
- 'android:exported': 'true'
40
+ 'android:exported': 'true',
33
41
  },
34
42
  'intent-filter': [
35
43
  {
@@ -43,4 +51,36 @@ function withRaiidrVoip(config) {
43
51
  });
44
52
  }
45
53
 
46
- module.exports = withRaiidrVoip;
54
+ /**
55
+ * IOS CONFIGURATION
56
+ */
57
+ function withIosConfig(config) {
58
+ return withInfoPlist(config, (config) => {
59
+ const infoPlist = config.modResults;
60
+
61
+ // 1. Add background modes
62
+ if (!infoPlist.UIBackgroundModes) {
63
+ infoPlist.UIBackgroundModes = [];
64
+ }
65
+
66
+ ['voip', 'audio'].forEach((mode) => {
67
+ if (!infoPlist.UIBackgroundModes.includes(mode)) {
68
+ infoPlist.UIBackgroundModes.push(mode);
69
+ }
70
+ });
71
+
72
+ // 2. Add descriptions for permissions
73
+ infoPlist.NSMicrophoneUsageDescription =
74
+ infoPlist.NSMicrophoneUsageDescription || 'Allow Raiidr to access your microphone for calls.';
75
+
76
+ return config;
77
+ });
78
+ }
79
+
80
+ // Export the combined plugin
81
+ module.exports = (config) => {
82
+ return withPlugins(config, [
83
+ withAndroidConfig,
84
+ withIosConfig,
85
+ ]);
86
+ };