@poolse/react-native 2.17.0 → 2.18.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/dist/index.js CHANGED
@@ -5876,7 +5876,7 @@ function CallScreen({
5876
5876
  if (!ringing && !showingIncoming) return;
5877
5877
  try {
5878
5878
  const start = ringing ? inCallManager?.startRingback : inCallManager?.startRingtone;
5879
- start?.("_DEFAULT_");
5879
+ start?.(ringing ? "_BUNDLE_" : "_DEFAULT_");
5880
5880
  } catch {
5881
5881
  }
5882
5882
  return () => {
@@ -6191,6 +6191,9 @@ function useVoipCalls({
6191
6191
  }) {
6192
6192
  const poolse = usePoolse();
6193
6193
  const shown = useRef(/* @__PURE__ */ new Map());
6194
+ const [voipToken, setVoipToken] = useState(null);
6195
+ const { me } = useMe();
6196
+ const registered = useRef(null);
6194
6197
  const handlers = useRef({ onAnswer, onDecline, calls });
6195
6198
  handlers.current = { onAnswer, onDecline, calls };
6196
6199
  const staleRef = useRef(staleAfterMs);
@@ -6230,6 +6233,20 @@ function useVoipCalls({
6230
6233
  void ready.current.then(done, done);
6231
6234
  if (isStalePush(sentAt, Date.now(), staleRef.current)) dismiss.current(call.callId);
6232
6235
  });
6236
+ useEffect(() => {
6237
+ const userId = me?.id;
6238
+ if (!voipToken || !userId) return;
6239
+ const pair = `${userId}:${voipToken}`;
6240
+ if (registered.current === pair) return;
6241
+ void poolse.devices.register({
6242
+ token: voipToken,
6243
+ platform: "ios",
6244
+ environment: apnsEnvironment ?? guessApnsEnvironment()
6245
+ }).then(() => {
6246
+ registered.current = pair;
6247
+ }).catch(() => {
6248
+ });
6249
+ }, [poolse, voipToken, me?.id, apnsEnvironment]);
6233
6250
  useEffect(() => {
6234
6251
  let cancelled = false;
6235
6252
  const fromPush = (payload) => {
@@ -6262,12 +6279,7 @@ function useVoipCalls({
6262
6279
  });
6263
6280
  voipPush.addEventListener("register", ((token) => {
6264
6281
  if (cancelled || !token) return;
6265
- void poolse.devices.register({
6266
- token,
6267
- platform: "ios",
6268
- environment: apnsEnvironment ?? guessApnsEnvironment()
6269
- }).catch(() => {
6270
- });
6282
+ setVoipToken(token);
6271
6283
  }));
6272
6284
  voipPush.addEventListener("notification", ((payload) => {
6273
6285
  fromPush(payload);