@poolse/native 3.6.2 → 3.7.1
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/CHANGELOG.md +25 -0
- package/README.md +119 -7
- package/android/src/main/java/dev/poolse/callcore/Ports.kt +2 -0
- package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +30 -2
- package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +59 -6
- package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +7 -0
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +112 -12
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallLook.kt +107 -0
- package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +98 -0
- package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +3 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js.map +1 -1
- package/ios/Module/PoolseCallsModule.swift +2 -0
- package/ios/Platform/CallKitController.swift +12 -0
- package/ios/Platform/CallRingtone.swift +86 -0
- package/package.json +1 -1
- package/plugin/bundledSound.js +86 -0
- package/plugin/index.js +14 -0
- package/plugin/withIncomingCall.js +74 -0
- package/plugin/withRingback.js +6 -80
- package/plugin/withRingtone.js +101 -0
- package/src/index.ts +41 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ringtone`: the sound an incoming call rings with, instead of the
|
|
3
|
+
* system ringtone.
|
|
4
|
+
*
|
|
5
|
+
* "ringtone": "./assets/sounds/ring.wav"
|
|
6
|
+
* "ringtone": { "ios": "./assets/sounds/ring.caf", "android": "./assets/sounds/ring.ogg" }
|
|
7
|
+
*
|
|
8
|
+
* iOS: CallKit plays it (`CXProviderConfiguration.ringtoneSound`), so it
|
|
9
|
+
* must be caf, aiff or wav and 30 seconds or shorter — iOS rings with the
|
|
10
|
+
* system ringtone otherwise. The file goes into the app bundle and its
|
|
11
|
+
* name into Info.plist `PoolseRingtone`, where the core reads it at a
|
|
12
|
+
* PushKit cold wake, before any JS.
|
|
13
|
+
*
|
|
14
|
+
* Android: the core plays it itself (looping, on the ringtone stream)
|
|
15
|
+
* from `res/raw/<name>`; use a format MediaPlayer reads (ogg, mp3, wav —
|
|
16
|
+
* not caf). The name goes into the application meta-data
|
|
17
|
+
* `dev.poolse.calls.ringtone`. The incoming-call notification channel
|
|
18
|
+
* stays silent, so changing the sound later needs no new channel.
|
|
19
|
+
*
|
|
20
|
+
* Both: lowercase letters, digits and underscores in the file name (an
|
|
21
|
+
* Android resource name), and not the same base name as `ringback`.
|
|
22
|
+
* `configure({ ringtone })` at runtime overrides this; leaving it out
|
|
23
|
+
* there falls back to this one.
|
|
24
|
+
*/
|
|
25
|
+
const { withAndroidManifest, withInfoPlist } = require('expo/config-plugins');
|
|
26
|
+
const path = require('node:path');
|
|
27
|
+
|
|
28
|
+
const { ANDROID_NAME, withAndroidRawSound, withIosBundleSound } = require('./bundledSound');
|
|
29
|
+
|
|
30
|
+
const PLIST_KEY = 'PoolseRingtone';
|
|
31
|
+
const META_NAME = 'dev.poolse.calls.ringtone';
|
|
32
|
+
const IOS_EXTENSIONS = ['.caf', '.aiff', '.aif', '.wav'];
|
|
33
|
+
const MISSING = 'Without it calls ring with the system ringtone.';
|
|
34
|
+
|
|
35
|
+
function split(option) {
|
|
36
|
+
if (typeof option === 'string') return { ios: option, android: option };
|
|
37
|
+
if (option && typeof option === 'object') return { ios: option.ios, android: option.android };
|
|
38
|
+
throw new Error('@poolse/native: ringtone must be a file path or { ios, android }.');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* One Info.plist and one manifest mod that both clear and set: mods run
|
|
43
|
+
* in reverse order of registration, so a separate "clear" mod registered
|
|
44
|
+
* first would run last and undo the value.
|
|
45
|
+
*/
|
|
46
|
+
function withRingtoneNames(config, plistValue, metaValue) {
|
|
47
|
+
config = withInfoPlist(config, (cfg) => {
|
|
48
|
+
if (plistValue) cfg.modResults[PLIST_KEY] = plistValue;
|
|
49
|
+
else delete cfg.modResults[PLIST_KEY];
|
|
50
|
+
return cfg;
|
|
51
|
+
});
|
|
52
|
+
return withAndroidManifest(config, (cfg) => {
|
|
53
|
+
const app = cfg.modResults.manifest.application?.[0];
|
|
54
|
+
if (!app) throw new Error('withRingtone: no <application> in AndroidManifest');
|
|
55
|
+
app['meta-data'] = (app['meta-data'] ?? []).filter((m) => m.$?.['android:name'] !== META_NAME);
|
|
56
|
+
if (metaValue)
|
|
57
|
+
app['meta-data'].push({ $: { 'android:name': META_NAME, 'android:value': metaValue } });
|
|
58
|
+
return cfg;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = function withRingtone(config, option, ringback) {
|
|
63
|
+
// Without the option this still runs, removing what an earlier prebuild wrote.
|
|
64
|
+
if (!option) return withRingtoneNames(config, null, null);
|
|
65
|
+
const { ios, android } = split(option);
|
|
66
|
+
const ringbackName = ringback ? path.parse(ringback).name : null;
|
|
67
|
+
|
|
68
|
+
if (ios) {
|
|
69
|
+
const ext = path.extname(ios).toLowerCase();
|
|
70
|
+
if (!IOS_EXTENSIONS.includes(ext)) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`@poolse/native: ringtone "${path.basename(ios)}" — CallKit plays only ` +
|
|
73
|
+
`${IOS_EXTENSIONS.join(', ')} (30 s or shorter). Convert it, e.g. ` +
|
|
74
|
+
'`afconvert -f caff -d LEI16 ring.mp3 ring.caf`, or pass { ios, android }.',
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (!ANDROID_NAME.test(path.parse(ios).name)) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`@poolse/native: ringtone "${path.basename(ios)}" — use lowercase letters, ` +
|
|
80
|
+
'digits and underscores in the name.',
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
config = withIosBundleSound(config, ios, 'ringtone', MISSING);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (android) {
|
|
87
|
+
const name = path.parse(android).name;
|
|
88
|
+
if (name === ringbackName) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`@poolse/native: ringtone and ringback are both "${name}" — Android keeps ` +
|
|
91
|
+
'one res/raw entry per name. Rename one of them.',
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
config = withAndroidRawSound(config, android, 'ringtone', MISSING);
|
|
95
|
+
}
|
|
96
|
+
return withRingtoneNames(
|
|
97
|
+
config,
|
|
98
|
+
ios ? path.basename(ios) : null,
|
|
99
|
+
android ? path.parse(android).name : null,
|
|
100
|
+
);
|
|
101
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -131,6 +131,23 @@ export interface ConfigureOptions {
|
|
|
131
131
|
smallIcon?: string;
|
|
132
132
|
/** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */
|
|
133
133
|
ringback?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Incoming ringtone, overriding the config plugin's `ringtone` (leave it
|
|
136
|
+
* out to use the plugin's, or the system ringtone without one).
|
|
137
|
+
* Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by
|
|
138
|
+
* the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the
|
|
139
|
+
* base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so
|
|
140
|
+
* a ring that wakes a closed app uses it too. A name that is not in the
|
|
141
|
+
* app rings with the system ringtone.
|
|
142
|
+
*/
|
|
143
|
+
ringtone?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Android: the full-screen incoming-call screen. Each field overrides the
|
|
146
|
+
* config plugin's `incomingCall` option; leave one out to keep the
|
|
147
|
+
* plugin's (or the built-in) value. Persisted for closed-app rings.
|
|
148
|
+
* Ignored on iOS, where CallKit draws the call screen.
|
|
149
|
+
*/
|
|
150
|
+
incomingCall?: IncomingCallOptions;
|
|
134
151
|
/**
|
|
135
152
|
* iOS: the APNs environment of this build's `aps-environment`
|
|
136
153
|
* entitlement. Echoed back with the VoIP token so the server pushes to
|
|
@@ -139,6 +156,30 @@ export interface ConfigureOptions {
|
|
|
139
156
|
apnsEnvironment?: 'production' | 'sandbox';
|
|
140
157
|
}
|
|
141
158
|
|
|
159
|
+
/** Android's full-screen incoming call: its look, or the app's own activity instead. */
|
|
160
|
+
export interface IncomingCallOptions {
|
|
161
|
+
/** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */
|
|
162
|
+
accentColor?: string;
|
|
163
|
+
/** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */
|
|
164
|
+
backgroundColor?: string;
|
|
165
|
+
/**
|
|
166
|
+
* The caller's picture, as a URL template: `{externalId}` (your app's id
|
|
167
|
+
* for the caller) and `{userId}` (the poolse user id) are filled in,
|
|
168
|
+
* URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.
|
|
169
|
+
* Loaded off the main thread; the initials show until it loads, or if it
|
|
170
|
+
* fails. A ring push's own `caller_avatar_url` wins over the template.
|
|
171
|
+
*/
|
|
172
|
+
avatarUrl?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Fully qualified class name of your own Activity (declared in your
|
|
175
|
+
* manifest) to launch instead of the built-in screen. It receives the
|
|
176
|
+
* `PoolseIncomingCall.EXTRA_*` extras and answers / declines through
|
|
177
|
+
* `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).
|
|
178
|
+
* A leading `.` is relative to the application id.
|
|
179
|
+
*/
|
|
180
|
+
activity?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
142
183
|
/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */
|
|
143
184
|
export interface VoipToken {
|
|
144
185
|
/** Hex-encoded PushKit token. */
|