rns-nativecall 1.1.3 → 1.1.5
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.
|
@@ -118,6 +118,14 @@ object NativeCallManager {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
fun refreshNotificationOnly(
|
|
122
|
+
context: Context,
|
|
123
|
+
uuid: String,
|
|
124
|
+
) {
|
|
125
|
+
val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
126
|
+
manager.cancel(uuid.hashCode())
|
|
127
|
+
}
|
|
128
|
+
|
|
121
129
|
fun dismissIncomingCall(
|
|
122
130
|
context: Context,
|
|
123
131
|
uuid: String?,
|
|
@@ -12,15 +12,10 @@ class UnlockReceiver : BroadcastReceiver() {
|
|
|
12
12
|
) {
|
|
13
13
|
if (intent.action == Intent.ACTION_USER_PRESENT) {
|
|
14
14
|
val activeData = NativeCallManager.getCurrentCallData()
|
|
15
|
-
|
|
16
15
|
if (activeData != null) {
|
|
17
|
-
//
|
|
18
|
-
|
|
16
|
+
val uuid = activeData["callUuid"] ?: "" // Use map access [] instead of getString
|
|
17
|
+
NativeCallManager.refreshNotificationOnly(context, uuid)
|
|
19
18
|
NativeCallManager.handleIncomingPush(context, activeData)
|
|
20
|
-
|
|
21
|
-
// Optional: If you want to force the React Native app to open
|
|
22
|
-
// immediately upon unlock without the user touching the banner:
|
|
23
|
-
// NativeCallManager.launchApp(context)
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
21
|
}
|
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -40,7 +40,6 @@ function withMainActivityDataFix(config) {
|
|
|
40
40
|
`;
|
|
41
41
|
|
|
42
42
|
if (contents.includes('override fun onCreate')) {
|
|
43
|
-
// If onCreate exists, inject logic after super.onCreate
|
|
44
43
|
if (!contents.includes('setShowWhenLocked(true)')) {
|
|
45
44
|
contents = contents.replace(
|
|
46
45
|
/super\.onCreate\(.*\)/,
|
|
@@ -49,23 +48,27 @@ function withMainActivityDataFix(config) {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
// 3. Inject
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
// 3. Handle onNewIntent (Inject method if missing, or fix if exists)
|
|
52
|
+
if (!contents.includes('override fun onNewIntent')) {
|
|
53
|
+
const onNewIntentCode = `
|
|
54
|
+
override fun onNewIntent(intent: Intent) {
|
|
55
|
+
super.onNewIntent(intent)
|
|
56
|
+
setIntent(intent)
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
contents = contents.replace(/class MainActivity\s*:\s*ReactActivity\(\)\s*\{/, (match) => `${match}${onNewIntentCode}`);
|
|
60
|
+
} else if (!contents.includes('setIntent(intent)')) {
|
|
61
|
+
contents = contents.replace(
|
|
62
|
+
/super\.onNewIntent\(intent\)/,
|
|
63
|
+
(match) => `super.onNewIntent(intent)\n setIntent(intent)`
|
|
64
|
+
);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
config.modResults.contents = contents;
|
|
66
68
|
return config;
|
|
67
69
|
});
|
|
68
70
|
}
|
|
71
|
+
|
|
69
72
|
/** 2. ANDROID MANIFEST CONFIG **/
|
|
70
73
|
function withAndroidConfig(config) {
|
|
71
74
|
return withAndroidManifest(config, (config) => {
|
|
@@ -166,19 +169,17 @@ function withAndroidConfig(config) {
|
|
|
166
169
|
return config;
|
|
167
170
|
});
|
|
168
171
|
}
|
|
169
|
-
|
|
172
|
+
|
|
173
|
+
/** 2. IOS APP DELEGATE MOD **/
|
|
170
174
|
function withIosAppDelegateMod(config) {
|
|
171
175
|
return withAppDelegate(config, (config) => {
|
|
172
176
|
let contents = config.modResults.contents;
|
|
173
177
|
|
|
174
|
-
// 1. Surgical Import: Add 'import React' at the very top if missing
|
|
175
178
|
if (!contents.includes('import React')) {
|
|
176
179
|
contents = 'import React\n' + contents;
|
|
177
180
|
}
|
|
178
181
|
|
|
179
|
-
// 2. Check for the continue userActivity method
|
|
180
182
|
if (!contents.includes('continue userActivity')) {
|
|
181
|
-
// Method is missing, inject it before the final closing brace of the class
|
|
182
183
|
const swiftLinkingCode = `
|
|
183
184
|
// Universal Links
|
|
184
185
|
public override func application(
|
|
@@ -190,10 +191,8 @@ function withIosAppDelegateMod(config) {
|
|
|
190
191
|
return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
|
|
191
192
|
}
|
|
192
193
|
`;
|
|
193
|
-
// This regex finds the last '}' in the file (closing the AppDelegate class)
|
|
194
194
|
contents = contents.replace(/\n}\s*$/, `\n${swiftLinkingCode}\n}`);
|
|
195
195
|
} else if (!contents.includes('RCTLinkingManager.application')) {
|
|
196
|
-
// Method exists but is missing our logic, inject it inside
|
|
197
196
|
contents = contents.replace(
|
|
198
197
|
/continue userActivity: NSUserActivity,[\s\S]*?\) -> Bool \{/,
|
|
199
198
|
`continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {\n let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)`
|
|
@@ -204,7 +203,8 @@ function withIosAppDelegateMod(config) {
|
|
|
204
203
|
return config;
|
|
205
204
|
});
|
|
206
205
|
}
|
|
207
|
-
|
|
206
|
+
|
|
207
|
+
/** 3. IOS INFO.PLIST CONFIG **/
|
|
208
208
|
function withIosConfig(config, props = {}) {
|
|
209
209
|
return withInfoPlist(config, (config) => {
|
|
210
210
|
const infoPlist = config.modResults;
|
|
@@ -219,12 +219,13 @@ function withIosConfig(config, props = {}) {
|
|
|
219
219
|
return config;
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
+
|
|
222
223
|
// Main Plugin Entry
|
|
223
224
|
module.exports = (config, props) => {
|
|
224
225
|
return withPlugins(config, [
|
|
225
226
|
withAndroidConfig,
|
|
226
227
|
withMainActivityDataFix,
|
|
227
|
-
withIosAppDelegateMod,
|
|
228
|
+
withIosAppDelegateMod,
|
|
228
229
|
[withIosConfig, props]
|
|
229
230
|
]);
|
|
230
231
|
};
|