Skip to content

Commit 7f2e4fb

Browse files
committed
Minor fixes
1 parent ecb67b3 commit 7f2e4fb

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

app/definitions/rest/v1/push.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type TPushInfo = {
66

77
export type PushEndpoints = {
88
'push.token': {
9-
POST: (params: { value: string; type: string; appName: string; voipToken?: string }) => {
9+
POST: (params: { id: string; value: string; type: string; appName: string; voipToken?: string }) => {
1010
result: {
1111
id: string;
1212
token: string;

app/lib/services/restApi.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,10 @@ export const registerPushToken = async (): Promise<void> => {
10171017
// Always returns an empty string on Android
10181018
const voipToken = NativeVoipModule.getLastVoipToken();
10191019

1020+
if (!token) {
1021+
return;
1022+
}
1023+
10201024
if (token === lastToken && voipToken === lastVoipToken) {
10211025
return;
10221026
}
@@ -1027,18 +1031,17 @@ export const registerPushToken = async (): Promise<void> => {
10271031
}
10281032

10291033
let data: TRegisterPushTokenData = {
1030-
id: '',
1034+
id: await getUniqueId(),
10311035
value: '',
10321036
type: '',
1033-
appName: ''
1037+
appName: getBundleId
10341038
};
10351039
if (token) {
10361040
const type = isIOS ? 'apn' : 'gcm';
10371041
data = {
1038-
id: await getUniqueId(),
1042+
...data,
10391043
value: token,
1040-
type,
1041-
appName: getBundleId
1044+
type
10421045
};
10431046
}
10441047
if (voipToken) {

app/lib/services/voip/MediaSessionInstance.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@rocket.chat/media-signaling';
99
import RNCallKeep from 'react-native-callkeep';
1010
import { registerGlobals } from 'react-native-webrtc';
11+
import { getUniqueId } from 'react-native-device-info';
1112

1213
import { mediaSessionStore } from './MediaSessionStore';
1314
import { useCallStore } from './useCallStore';
@@ -61,6 +62,11 @@ class MediaSessionInstance {
6162
}
6263
const signal = ddpMessage.fields.args[0];
6364
this.instance.processSignal(signal);
65+
66+
// If the call was accepted from another device, end the call
67+
if (signal.type === 'notification' && signal.notification === 'accepted' && signal.signedContractId !== getUniqueId()) {
68+
// TODO: pop from call view, end callkeep and remove incoming call notification
69+
}
6470
});
6571

6672
this.instance?.on('newCall', ({ call }: { call: IClientMediaCall }) => {

app/lib/services/voip/useCallStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export const useCallStore = create<CallStore>((set, get) => ({
172172
set({ dialpadValue: newValue });
173173
},
174174

175+
// TODO: do it here or in MediaSessionInstance?
175176
endCall: () => {
176177
const { call, callId } = get();
177178

ios/Libraries/AppDelegate+Voip.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ extension AppDelegate: PKPushRegistryDelegate {
2121
let payloadDict = payload.dictionaryPayload
2222

2323
guard let voipPayload = VoipPayload.fromDictionary(payloadDict) else {
24-
print("Failed to parse incoming VoIP payload")
24+
#if DEBUG
25+
print("[\(TAG)] Failed to parse incoming VoIP payload")
26+
#endif
2527
completion()
2628
return
2729
}
2830

2931
let callId = voipPayload.callId
3032
let caller = voipPayload.caller
3133
guard !voipPayload.isExpired() else {
32-
print("Skipping expired or invalid VoIP payload for callId: \(callId)")
34+
#if DEBUG
35+
print("[\(TAG)] Skipping expired or invalid VoIP payload for callId: \(callId)")
36+
#endif
3337
completion()
3438
return
3539
}

ios/Libraries/VoipService.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ public final class VoipService: NSObject {
303303
}
304304

305305
client.connect(host: payload.host) { connected in
306-
print("[\(TAG)] DDP connection callback")
307306
guard ddpClient === client else {
308307
return
309308
}

0 commit comments

Comments
 (0)