rns-nativecall 0.2.6 → 0.2.8

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.
@@ -1,43 +1,71 @@
1
+ // 1. Buildscript defines WHERE to get the plugins
2
+ buildscript {
3
+ ext.kotlin_version = project.hasProperty('kotlinVersion') ? project.kotlinVersion : '1.8.10'
4
+ repositories {
5
+ google()
6
+ mavenCentral()
7
+ }
8
+ dependencies {
9
+ classpath "com.android.tools.build:gradle:7.4.2"
10
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11
+ }
12
+ }
13
+
14
+ // 2. Apply the plugins immediately after buildscript
15
+ apply plugin: 'com.android.library'
16
+ apply plugin: 'kotlin-android'
17
+
18
+ // 3. Define helper functions
19
+ def safeExtGet(prop, fallback) {
20
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
21
+ }
22
+
23
+ // 4. The Android block - should now be recognized
1
24
  android {
2
- // 1. MATCH NAMESPACE: Ensure this matches the package in your .kt files
25
+ // Crucial for AGP 7+
3
26
  namespace "com.rnsnativecall"
4
27
 
5
- // 2. TARGET SDK: Android 13 (API 33) is the standard for modern RN apps
6
- // This allows you to use the POST_NOTIFICATIONS permission needed for Android 13+
7
28
  compileSdkVersion safeExtGet('compileSdkVersion', 33)
8
29
 
9
30
  defaultConfig {
10
31
  minSdkVersion safeExtGet('minSdkVersion', 21)
11
32
  targetSdkVersion safeExtGet('targetSdkVersion', 33)
12
33
 
13
- // Ensure your library can handle vector icons if you use them in notifications
14
- vectorDrawables.useSupportLibrary = true
34
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
35
+ }
36
+
37
+ compileOptions {
38
+ sourceCompatibility JavaVersion.VERSION_17
39
+ targetCompatibility JavaVersion.VERSION_17
15
40
  }
16
41
 
17
- // 3. KOTLIN OPTIONS: Essential for smooth bridge communication
18
42
  kotlinOptions {
19
- jvmTarget = '1.8'
43
+ jvmTarget = '17' // Changed from 1.8
20
44
  }
21
45
 
22
- lintOptions {
46
+ // lintOptions is deprecated in newer AGP, using lint instead
47
+ lint {
23
48
  abortOnError false
24
49
  }
25
50
  }
26
51
 
52
+ repositories {
53
+ mavenCentral()
54
+ google()
55
+ }
56
+
27
57
  dependencies {
28
- implementation "com.facebook.react:react-native:+"
29
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
58
+ // Use 'provided' or 'implementation' depending on how you want to link RN
59
+ // For most modules, we use implementation but let the app provide the actual binary
60
+ implementation "com.facebook.react:react-native:+"
30
61
 
31
- // Firebase - Use a stable version that supports Android 13+
62
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
32
63
  implementation "com.google.firebase:firebase-messaging:23.4.0"
33
-
34
- // UI & Design
35
64
  implementation "androidx.appcompat:appcompat:1.6.1"
36
- implementation "androidx.core:core-ktx:1.10.1" // Required for NotificationCompat
65
+ implementation "androidx.core:core-ktx:1.10.1"
37
66
  implementation "com.google.android.material:material:1.9.0"
38
-
39
- // 4. Glide for Profile Pictures
40
- // If you plan to show the caller's face in the notification
67
+
68
+ // Glide for profile pictures
41
69
  implementation "com.github.bumptech.glide:glide:4.15.1"
42
70
  annotationProcessor "com.github.bumptech.glide:compiler:4.15.1"
43
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "RNS 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",
@@ -5,12 +5,10 @@ function withMainActivityDataFix(config) {
5
5
  return withMainActivity(config, (config) => {
6
6
  let contents = config.modResults.contents;
7
7
 
8
- // Ensure Intent import exists
9
8
  if (!contents.includes('import android.content.Intent')) {
10
9
  contents = contents.replace(/package .*/, (match) => `${match}\n\nimport android.content.Intent`);
11
10
  }
12
11
 
13
- // Add onNewIntent to catch data when app is open
14
12
  const onNewIntentCode = `
15
13
  override fun onNewIntent(intent: Intent) {
16
14
  super.onNewIntent(intent)
@@ -34,15 +32,15 @@ function withAndroidConfig(config) {
34
32
  const manifest = config.modResults;
35
33
  const application = manifest.manifest.application[0];
36
34
 
37
- // 1. Updated Permissions for Custom Notifications & Android 13/14
35
+ // 1. Unified Permissions
38
36
  const permissions = [
39
37
  'android.permission.USE_FULL_SCREEN_INTENT',
40
38
  'android.permission.VIBRATE',
41
39
  'android.permission.FOREGROUND_SERVICE',
42
- 'android.permission.FOREGROUND_SERVICE_PHONE_CALL', // Required for Android 14
43
- 'android.permission.POST_NOTIFICATIONS', // Required for Android 13+
44
- 'android.permission.WAKE_LOCK', // Helps wake the screen
45
- 'android.permission.DISABLE_KEYGUARD' // Allows showing over lockscreen
40
+ 'android.permission.FOREGROUND_SERVICE_PHONE_CALL',
41
+ 'android.permission.POST_NOTIFICATIONS',
42
+ 'android.permission.WAKE_LOCK',
43
+ 'android.permission.DISABLE_KEYGUARD'
46
44
  ];
47
45
 
48
46
  manifest.manifest['uses-permission'] = manifest.manifest['uses-permission'] || [];
@@ -52,51 +50,54 @@ function withAndroidConfig(config) {
52
50
  }
53
51
  });
54
52
 
55
- // 2. AcceptCallActivity - The "Pill" UI handler
56
- // Added showWhenLocked and turnScreenOn for the "Gate" logic
53
+ // 2. Activity Cleanup & Setup
57
54
  application.activity = application.activity || [];
58
- const acceptActivityName = 'com.rnsnativecall.AcceptCallActivity';
59
55
 
60
- // Remove old entry if exists to avoid duplicates
61
- application.activity = application.activity.filter(a => a.$['android:name'] !== acceptActivityName);
56
+ // Remove old/redundant activities
57
+ application.activity = application.activity.filter(a =>
58
+ a.$['android:name'] !== 'com.rnsnativecall.IncomingCallActivity' &&
59
+ a.$['android:name'] !== 'com.rnsnativecall.AcceptCallActivity'
60
+ );
62
61
 
62
+ // Add the specific AcceptCallActivity (Trampoline)
63
63
  application.activity.push({
64
64
  $: {
65
- 'android:name': acceptActivityName,
65
+ 'android:name': 'com.rnsnativecall.AcceptCallActivity',
66
66
  'android:theme': '@android:style/Theme.Translucent.NoTitleBar',
67
67
  'android:excludeFromRecents': 'true',
68
68
  'android:noHistory': 'true',
69
69
  'android:exported': 'false',
70
70
  'android:launchMode': 'singleInstance',
71
- 'android:showWhenLocked': 'true', // CRUCIAL: Show over lockscreen
72
- 'android:turnScreenOn': 'true' // CRUCIAL: Wake device
71
+ 'android:showWhenLocked': 'true',
72
+ 'android:turnScreenOn': 'true'
73
73
  }
74
74
  });
75
75
 
76
- // 3. Updated Services
76
+ // 3. Service Cleanup & Setup (Firebase only)
77
77
  application.service = application.service || [];
78
- // Removed MyConnectionService as you are no longer using Telecom
79
- const services = [
80
- { name: 'com.rnsnativecall.CallMessagingService', action: 'com.google.firebase.MESSAGING_EVENT' }
81
- ];
82
78
 
83
- services.forEach(svc => {
84
- if (!application.service.some(s => s.$['android:name'] === svc.name)) {
85
- application.service.push({
86
- $: {
87
- 'android:name': svc.name,
88
- 'android:exported': 'false' // Firebase services should usually be false unless needed
89
- },
90
- 'intent-filter': [{ action: [{ $: { 'android:name': svc.action } }] }]
91
- });
92
- }
93
- });
79
+ // Explicitly remove Telecom Service
80
+ application.service = application.service.filter(
81
+ s => s.$['android:name'] !== 'com.rnsnativecall.MyConnectionService'
82
+ );
83
+
84
+ const firebaseServiceName = 'com.rnsnativecall.CallMessagingService';
85
+ if (!application.service.some(s => s.$['android:name'] === firebaseServiceName)) {
86
+ application.service.push({
87
+ $: {
88
+ 'android:name': firebaseServiceName,
89
+ 'android:exported': 'false'
90
+ },
91
+ 'intent-filter': [{ action: [{ $: { 'android:name': 'com.google.firebase.MESSAGING_EVENT' } }] }]
92
+ });
93
+ }
94
94
 
95
- // 4. Receivers (Answer/Reject Buttons)
95
+ // 4. Receiver Setup
96
96
  application.receiver = application.receiver || [];
97
- if (!application.receiver.some(r => r.$['android:name'] === 'com.rnsnativecall.CallActionReceiver')) {
97
+ const receiverName = 'com.rnsnativecall.CallActionReceiver';
98
+ if (!application.receiver.some(r => r.$['android:name'] === receiverName)) {
98
99
  application.receiver.push({
99
- $: { 'android:name': 'com.rnsnativecall.CallActionReceiver', 'android:exported': 'false' }
100
+ $: { 'android:name': receiverName, 'android:exported': 'false' }
100
101
  });
101
102
  }
102
103
 
@@ -109,7 +110,9 @@ function withIosConfig(config) {
109
110
  return withInfoPlist(config, (config) => {
110
111
  const infoPlist = config.modResults;
111
112
  if (!infoPlist.UIBackgroundModes) infoPlist.UIBackgroundModes = [];
112
- ['voip', 'audio'].forEach(mode => { if (!infoPlist.UIBackgroundModes.includes(mode)) infoPlist.UIBackgroundModes.push(mode); });
113
+ ['voip', 'audio'].forEach(mode => {
114
+ if (!infoPlist.UIBackgroundModes.includes(mode)) infoPlist.UIBackgroundModes.push(mode);
115
+ });
113
116
  return config;
114
117
  });
115
118
  }