@stream-io/video-react-native-sdk 1.2.14 → 1.3.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/CHANGELOG.md +13 -0
- package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js +43 -6
- package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +1 -1
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +2 -2
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +2 -7
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +1 -1
- package/dist/commonjs/hooks/push/useProcessPushNonRingingCallEffect.js +3 -3
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +1 -0
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/providers/StreamCall.js +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +5 -6
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/index.js +12 -0
- package/dist/commonjs/utils/index.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +23 -79
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/index.js +39 -0
- package/dist/commonjs/utils/push/index.js.map +1 -0
- package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -0
- package/dist/commonjs/utils/push/internal/utils.js +157 -0
- package/dist/commonjs/utils/push/internal/utils.js.map +1 -0
- package/dist/commonjs/utils/push/ios.js +43 -84
- package/dist/commonjs/utils/push/ios.js.map +1 -1
- package/dist/commonjs/utils/push/libs/expoNotifications.js.map +1 -1
- package/dist/commonjs/utils/push/libs/index.js +0 -11
- package/dist/commonjs/utils/push/libs/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/iosPushNotification.js.map +1 -1
- package/dist/commonjs/utils/push/utils.js +29 -150
- package/dist/commonjs/utils/push/utils.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/commonjs/version.js.map +1 -1
- package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js +41 -4
- package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +1 -1
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +2 -2
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/push/useProcessPushCallEffect.js +2 -7
- package/dist/module/hooks/push/useProcessPushCallEffect.js.map +1 -1
- package/dist/module/hooks/push/useProcessPushNonRingingCallEffect.js +3 -3
- package/dist/module/hooks/push/useProcessPushNonRingingCallEffect.js.map +1 -1
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +1 -0
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/providers/StreamCall.js +1 -1
- package/dist/module/providers/StreamCall.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +5 -6
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/index.js +1 -0
- package/dist/module/utils/index.js.map +1 -1
- package/dist/module/utils/push/android.js +20 -79
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/index.js +4 -0
- package/dist/module/utils/push/index.js.map +1 -0
- package/dist/module/utils/push/internal/rxSubjects.js.map +1 -0
- package/dist/module/utils/push/internal/utils.js +146 -0
- package/dist/module/utils/push/internal/utils.js.map +1 -0
- package/dist/module/utils/push/ios.js +40 -81
- package/dist/module/utils/push/ios.js.map +1 -1
- package/dist/module/utils/push/libs/expoNotifications.js.map +1 -1
- package/dist/module/utils/push/libs/index.js +0 -1
- package/dist/module/utils/push/libs/index.js.map +1 -1
- package/dist/module/utils/push/libs/iosPushNotification.js.map +1 -1
- package/dist/module/utils/push/utils.js +25 -144
- package/dist/module/utils/push/utils.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/version.js.map +1 -1
- package/dist/typescript/hooks/push/useIosCallKeepEventsSetupEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +6 -4
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/index.d.ts +1 -0
- package/dist/typescript/utils/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/android.d.ts +12 -2
- package/dist/typescript/utils/push/android.d.ts.map +1 -1
- package/dist/typescript/utils/push/index.d.ts +4 -0
- package/dist/typescript/utils/push/index.d.ts.map +1 -0
- package/dist/typescript/utils/push/{rxSubjects.d.ts → internal/rxSubjects.d.ts} +1 -1
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -0
- package/dist/typescript/utils/push/internal/utils.d.ts +43 -0
- package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -0
- package/dist/typescript/utils/push/ios.d.ts +8 -3
- package/dist/typescript/utils/push/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/expoNotifications.d.ts +2 -0
- package/dist/typescript/utils/push/libs/expoNotifications.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/index.d.ts +0 -1
- package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/iosPushNotification.d.ts +2 -0
- package/dist/typescript/utils/push/libs/iosPushNotification.d.ts.map +1 -1
- package/dist/typescript/utils/push/utils.d.ts +14 -42
- package/dist/typescript/utils/push/utils.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/dist/typescript/version.d.ts.map +1 -1
- package/package.json +6 -11
- package/src/hooks/push/useIosCallKeepEventsSetupEffect.ts +62 -6
- package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +1 -1
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +2 -2
- package/src/hooks/push/useProcessPushCallEffect.ts +2 -7
- package/src/hooks/push/useProcessPushNonRingingCallEffect.ts +3 -3
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +1 -0
- package/src/providers/StreamCall.tsx +1 -1
- package/src/utils/StreamVideoRN/index.ts +11 -6
- package/src/utils/StreamVideoRN/types.ts +6 -4
- package/src/utils/index.ts +1 -0
- package/src/utils/push/android.ts +28 -99
- package/src/utils/push/index.ts +3 -0
- package/src/utils/push/{rxSubjects.ts → internal/rxSubjects.ts} +1 -1
- package/src/utils/push/internal/utils.ts +178 -0
- package/src/utils/push/ios.ts +49 -115
- package/src/utils/push/libs/expoNotifications.ts +4 -0
- package/src/utils/push/libs/index.ts +0 -1
- package/src/utils/push/libs/iosPushNotification.ts +4 -0
- package/src/utils/push/utils.ts +44 -175
- package/src/version.ts +1 -1
- package/dist/commonjs/utils/push/libs/expoTaskManager.js +0 -17
- package/dist/commonjs/utils/push/libs/expoTaskManager.js.map +0 -1
- package/dist/commonjs/utils/push/rxSubjects.js.map +0 -1
- package/dist/module/utils/push/libs/expoTaskManager.js +0 -11
- package/dist/module/utils/push/libs/expoTaskManager.js.map +0 -1
- package/dist/module/utils/push/rxSubjects.js.map +0 -1
- package/dist/typescript/utils/push/libs/expoTaskManager.d.ts +0 -3
- package/dist/typescript/utils/push/libs/expoTaskManager.d.ts.map +0 -1
- package/dist/typescript/utils/push/rxSubjects.d.ts.map +0 -1
- package/src/utils/push/libs/expoTaskManager.ts +0 -16
- /package/dist/commonjs/utils/push/{rxSubjects.js → internal/rxSubjects.js} +0 -0
- /package/dist/module/utils/push/{rxSubjects.js → internal/rxSubjects.js} +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldCallBeEnded = exports.processNonIncomingCallFromPush = exports.processCallFromPushInBackground = exports.processCallFromPush = exports.clearPushWSEventSubscriptions = exports.canAddPushWSSubscriptionsRef = void 0;
|
|
7
|
+
var _videoClient = require("@stream-io/video-client");
|
|
8
|
+
var _newNotificationCallbacks = require("../../internal/newNotificationCallbacks");
|
|
9
|
+
var _rxSubjects = require("./rxSubjects");
|
|
10
|
+
/**
|
|
11
|
+
* This function is used to check if the call should be ended based on the push notification
|
|
12
|
+
* Useful for callkeep management to end the call if necessary (with reportEndCallWithUUID)
|
|
13
|
+
*/
|
|
14
|
+
const shouldCallBeEnded = (callFromPush, created_by_id, receiver_id) => {
|
|
15
|
+
/* callkeep reasons for ending a call
|
|
16
|
+
FAILED: 1,
|
|
17
|
+
REMOTE_ENDED: 2,
|
|
18
|
+
UNANSWERED: 3,
|
|
19
|
+
ANSWERED_ELSEWHERE: 4,
|
|
20
|
+
DECLINED_ELSEWHERE: 5,
|
|
21
|
+
MISSED: 6
|
|
22
|
+
*/
|
|
23
|
+
const callSession = callFromPush.state.session;
|
|
24
|
+
const rejected_by = callSession?.rejected_by;
|
|
25
|
+
const accepted_by = callSession?.accepted_by;
|
|
26
|
+
let mustEndCall = false;
|
|
27
|
+
let callkeepReason = 0;
|
|
28
|
+
if (created_by_id && rejected_by) {
|
|
29
|
+
if (rejected_by[created_by_id]) {
|
|
30
|
+
// call was cancelled by the caller
|
|
31
|
+
mustEndCall = true;
|
|
32
|
+
callkeepReason = 2;
|
|
33
|
+
}
|
|
34
|
+
} else if (receiver_id && rejected_by) {
|
|
35
|
+
if (rejected_by[receiver_id]) {
|
|
36
|
+
// call was rejected by the receiver in some other device
|
|
37
|
+
mustEndCall = true;
|
|
38
|
+
callkeepReason = 5;
|
|
39
|
+
}
|
|
40
|
+
} else if (receiver_id && accepted_by) {
|
|
41
|
+
if (accepted_by[receiver_id]) {
|
|
42
|
+
// call was accepted by the receiver in some other device
|
|
43
|
+
mustEndCall = true;
|
|
44
|
+
callkeepReason = 4;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
mustEndCall,
|
|
49
|
+
callkeepReason
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/* An action for the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
|
|
54
|
+
1. we need to create a new client and connect the user to decline the call
|
|
55
|
+
2. this is because the app is in background state and we don't have a client to get the call and do an action
|
|
56
|
+
*/
|
|
57
|
+
exports.shouldCallBeEnded = shouldCallBeEnded;
|
|
58
|
+
const processCallFromPushInBackground = async (pushConfig, call_cid, action) => {
|
|
59
|
+
let videoClient;
|
|
60
|
+
try {
|
|
61
|
+
videoClient = await pushConfig.createStreamVideoClient();
|
|
62
|
+
if (!videoClient) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
const logger = (0, _videoClient.getLogger)(['processCallFromPushInBackground']);
|
|
67
|
+
logger('error', 'failed to create video client', e);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await processCallFromPush(videoClient, call_cid, action, pushConfig);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* This function is used process the call from push notifications due to incoming call
|
|
75
|
+
* It does the following steps:
|
|
76
|
+
* 1. Get the call from the client if present or create a new call
|
|
77
|
+
* 2. Fetch the latest state of the call from the server if its not already in ringing state
|
|
78
|
+
* 3. Join or leave the call based on the user's action.
|
|
79
|
+
*/
|
|
80
|
+
exports.processCallFromPushInBackground = processCallFromPushInBackground;
|
|
81
|
+
const processCallFromPush = async (client, call_cid, action, pushConfig) => {
|
|
82
|
+
let callFromPush;
|
|
83
|
+
try {
|
|
84
|
+
callFromPush = await client.onRingingCall(call_cid);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
const logger = (0, _videoClient.getLogger)(['processCallFromPush']);
|
|
87
|
+
logger('error', 'failed to fetch call from push notification', e);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// note: when action was pressed or delivered, we dont need to do anything as the only thing is to do is to get the call which adds it to the client
|
|
91
|
+
try {
|
|
92
|
+
if (action === 'accept') {
|
|
93
|
+
if (pushConfig.publishOptions) {
|
|
94
|
+
callFromPush.updatePublishOptions(pushConfig.publishOptions);
|
|
95
|
+
}
|
|
96
|
+
await callFromPush.join();
|
|
97
|
+
} else if (action === 'decline') {
|
|
98
|
+
await callFromPush.leave({
|
|
99
|
+
reject: true
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
const logger = (0, _videoClient.getLogger)(['processCallFromPush']);
|
|
104
|
+
logger('error', `failed to process ${action} call from push notification`, e);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* This function is used process the call from push notifications due to non ringing calls
|
|
110
|
+
* It does the following steps:
|
|
111
|
+
* 1. Get the call from the client if present or create a new call
|
|
112
|
+
* 2. Fetch the latest state of the call from the server
|
|
113
|
+
* 3. Call all the callbacks to inform the app about the call
|
|
114
|
+
*/
|
|
115
|
+
exports.processCallFromPush = processCallFromPush;
|
|
116
|
+
const processNonIncomingCallFromPush = async (client, call_cid, nonRingingNotificationType) => {
|
|
117
|
+
let callFromPush;
|
|
118
|
+
try {
|
|
119
|
+
const _callFromPush = client.state.calls.find(c => c.cid === call_cid);
|
|
120
|
+
if (_callFromPush) {
|
|
121
|
+
callFromPush = _callFromPush;
|
|
122
|
+
} else {
|
|
123
|
+
// if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
|
|
124
|
+
const [callType, callId] = call_cid.split(':');
|
|
125
|
+
callFromPush = client.call(callType, callId);
|
|
126
|
+
await callFromPush.get();
|
|
127
|
+
}
|
|
128
|
+
} catch (e) {
|
|
129
|
+
const logger = (0, _videoClient.getLogger)(['processNonIncomingCallFromPush']);
|
|
130
|
+
logger('error', 'failed to fetch call from push notification', e);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
(0, _newNotificationCallbacks.onNewCallNotification)(callFromPush, nonRingingNotificationType);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* This function is used to clear all the push related WS subscriptions
|
|
138
|
+
* note: events are subscribed in push for accept/decline through WS
|
|
139
|
+
*/
|
|
140
|
+
exports.processNonIncomingCallFromPush = processNonIncomingCallFromPush;
|
|
141
|
+
const clearPushWSEventSubscriptions = () => {
|
|
142
|
+
const unsubscriptionCallbacks = _videoClient.RxUtils.getCurrentValue(_rxSubjects.pushUnsubscriptionCallbacks$);
|
|
143
|
+
if (unsubscriptionCallbacks) {
|
|
144
|
+
unsubscriptionCallbacks.forEach(cb => cb());
|
|
145
|
+
}
|
|
146
|
+
_rxSubjects.pushUnsubscriptionCallbacks$.next(undefined);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* This ref is used to check if the push WS subscriptions can be added
|
|
151
|
+
* It is used to avoid adding the push WS subscriptions when the client is connected to WS in the foreground
|
|
152
|
+
*/
|
|
153
|
+
exports.clearPushWSEventSubscriptions = clearPushWSEventSubscriptions;
|
|
154
|
+
const canAddPushWSSubscriptionsRef = exports.canAddPushWSSubscriptionsRef = {
|
|
155
|
+
current: true
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_videoClient","require","_newNotificationCallbacks","_rxSubjects","shouldCallBeEnded","callFromPush","created_by_id","receiver_id","callSession","state","session","rejected_by","accepted_by","mustEndCall","callkeepReason","exports","processCallFromPushInBackground","pushConfig","call_cid","action","videoClient","createStreamVideoClient","e","logger","getLogger","processCallFromPush","client","onRingingCall","publishOptions","updatePublishOptions","join","leave","reject","processNonIncomingCallFromPush","nonRingingNotificationType","_callFromPush","calls","find","c","cid","callType","callId","split","call","get","onNewCallNotification","clearPushWSEventSubscriptions","unsubscriptionCallbacks","RxUtils","getCurrentValue","pushUnsubscriptionCallbacks$","forEach","cb","next","undefined","canAddPushWSSubscriptionsRef","current"],"sourceRoot":"../../../../../src","sources":["utils/push/internal/utils.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAUA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA;AACA;AACA;AACA;AACO,MAAMG,iBAAiB,GAAGA,CAC/BC,YAAkB,EAClBC,aAAiC,EACjCC,WAA+B,KAC5B;EACH;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,WAAW,GAAGH,YAAY,CAACI,KAAK,CAACC,OAAO;EAC9C,MAAMC,WAAW,GAAGH,WAAW,EAAEG,WAAW;EAC5C,MAAMC,WAAW,GAAGJ,WAAW,EAAEI,WAAW;EAC5C,IAAIC,WAAW,GAAG,KAAK;EACvB,IAAIC,cAAc,GAAG,CAAC;EACtB,IAAIR,aAAa,IAAIK,WAAW,EAAE;IAChC,IAAIA,WAAW,CAACL,aAAa,CAAC,EAAE;MAC9B;MACAO,WAAW,GAAG,IAAI;MAClBC,cAAc,GAAG,CAAC;IACpB;EACF,CAAC,MAAM,IAAIP,WAAW,IAAII,WAAW,EAAE;IACrC,IAAIA,WAAW,CAACJ,WAAW,CAAC,EAAE;MAC5B;MACAM,WAAW,GAAG,IAAI;MAClBC,cAAc,GAAG,CAAC;IACpB;EACF,CAAC,MAAM,IAAIP,WAAW,IAAIK,WAAW,EAAE;IACrC,IAAIA,WAAW,CAACL,WAAW,CAAC,EAAE;MAC5B;MACAM,WAAW,GAAG,IAAI;MAClBC,cAAc,GAAG,CAAC;IACpB;EACF;EACA,OAAO;IAAED,WAAW;IAAEC;EAAe,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AAHAC,OAAA,CAAAX,iBAAA,GAAAA,iBAAA;AAIO,MAAMY,+BAA+B,GAAG,MAAAA,CAC7CC,UAAsB,EACtBC,QAAgB,EAChBC,MA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uB,EAAE;IAC3BA,uBAAuB,CAACI,OAAO,CAAEC,EAAE,IAAKA,EAAE,CAAC,CAAC,CAAC;EAC/C;EACAF,wCAA4B,CAACG,IAAI,CAACC,SAAS,CAAC;AAC9C,CAAC;;AAED;AACA;AACA;AACA;AAHAvC,OAAA,CAAA+B,6BAAA,GAAAA,6BAAA;AAIO,MAAMS,4BAA0D,GAAAxC,OAAA,CAAAwC,4BAAA,GAAG;EACxEC,OAAO,EAAE;AACX,CAAC","ignoreList":[]}
|
|
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.initIosNonVoipToken = initIosNonVoipToken;
|
|
7
|
-
exports.
|
|
7
|
+
exports.onPushNotificationiOSStreamVideoEvent = onPushNotificationiOSStreamVideoEvent;
|
|
8
|
+
exports.oniOSNotifeeEvent = exports.oniOSExpoNotificationEvent = void 0;
|
|
8
9
|
var _reactNative = require("react-native");
|
|
9
|
-
var _rxSubjects = require("./rxSubjects");
|
|
10
|
-
var _utils = require("./utils");
|
|
10
|
+
var _rxSubjects = require("./internal/rxSubjects");
|
|
11
11
|
var _libs = require("./libs");
|
|
12
12
|
var _videoClient = require("@stream-io/video-client");
|
|
13
13
|
var _pushLogoutCallback = require("../internal/pushLogoutCallback");
|
|
14
|
+
var _reactNative2 = require("@notifee/react-native");
|
|
15
|
+
var _StreamVideoRN = require("../StreamVideoRN");
|
|
14
16
|
let lastApnToken = {
|
|
15
17
|
token: '',
|
|
16
18
|
userId: ''
|
|
@@ -29,80 +31,53 @@ function processNonRingingNotificationStreamPayload(streamPayload) {
|
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
uuid: callUUIDFromCallkeep,
|
|
40
|
-
cid: call_cid
|
|
41
|
-
});
|
|
42
|
-
// to process the call in the app
|
|
43
|
-
_rxSubjects.pushAcceptedIncomingCallCId$.next(call_cid);
|
|
44
|
-
// no need to keep these references anymore
|
|
45
|
-
_rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
46
|
-
};
|
|
47
|
-
exports.iosCallkeepAcceptCall = iosCallkeepAcceptCall;
|
|
48
|
-
const iosCallkeepRejectCall = async (call_cid, callUUIDFromCallkeep, pushConfig) => {
|
|
49
|
-
if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
(0, _utils.clearPushWSEventSubscriptions)();
|
|
53
|
-
// no need to keep these references anymore
|
|
54
|
-
_rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
55
|
-
_rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
56
|
-
_rxSubjects.voipPushNotificationCallCId$.next(undefined);
|
|
57
|
-
await (0, _utils.processCallFromPushInBackground)(pushConfig, call_cid, 'decline');
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Helper function to determine if the answer/end call event from callkeep must be processed
|
|
62
|
-
* Just checks if we have a valid call_cid and acts as a type guard for call_cid
|
|
63
|
-
*/
|
|
64
|
-
exports.iosCallkeepRejectCall = iosCallkeepRejectCall;
|
|
65
|
-
const shouldProcessCallFromCallkeep = (call_cid, callUUIDFromCallkeep) => {
|
|
66
|
-
if (!call_cid || !callUUIDFromCallkeep) {
|
|
67
|
-
return false;
|
|
34
|
+
const oniOSExpoNotificationEvent = event => {
|
|
35
|
+
const pushConfig = _StreamVideoRN.StreamVideoRN.getConfig().push;
|
|
36
|
+
if (pushConfig) {
|
|
37
|
+
if (event.request.trigger.type === 'push') {
|
|
38
|
+
const streamPayload = event.request.trigger.payload?.stream;
|
|
39
|
+
processNonRingingNotificationStreamPayload(streamPayload);
|
|
40
|
+
}
|
|
68
41
|
}
|
|
69
|
-
return true;
|
|
70
42
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
43
|
+
exports.oniOSExpoNotificationEvent = oniOSExpoNotificationEvent;
|
|
44
|
+
const oniOSNotifeeEvent = ({
|
|
45
|
+
event
|
|
46
|
+
}) => {
|
|
47
|
+
if (_reactNative.Platform.OS !== 'ios') return;
|
|
48
|
+
const pushConfig = _StreamVideoRN.StreamVideoRN.getConfig().push;
|
|
49
|
+
const {
|
|
77
50
|
type,
|
|
78
51
|
detail
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
52
|
+
} = event;
|
|
53
|
+
if (pushConfig && type === _reactNative2.EventType.PRESS) {
|
|
54
|
+
const streamPayload = detail.notification?.data?.stream;
|
|
55
|
+
const result = processNonRingingNotificationStreamPayload(streamPayload);
|
|
56
|
+
if (result) {
|
|
57
|
+
pushConfig.onTapNonRingingCallNotification?.(result.cid, result.type);
|
|
86
58
|
}
|
|
87
|
-
});
|
|
88
|
-
if (pushConfig.isExpo) {
|
|
89
|
-
const Notifications = (0, _libs.getExpoNotificationsLib)();
|
|
90
|
-
|
|
91
|
-
// foreground handler (just to show the notifications on foreground)
|
|
92
|
-
Notifications.setNotificationHandler({
|
|
93
|
-
handleNotification: async () => {
|
|
94
|
-
return {
|
|
95
|
-
shouldShowAlert: true,
|
|
96
|
-
shouldPlaySound: true,
|
|
97
|
-
shouldSetBadge: false
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
59
|
}
|
|
102
60
|
};
|
|
61
|
+
exports.oniOSNotifeeEvent = oniOSNotifeeEvent;
|
|
62
|
+
function onPushNotificationiOSStreamVideoEvent(notification) {
|
|
63
|
+
const pushNotificationIosLib = (0, _libs.getPushNotificationIosLib)();
|
|
64
|
+
const data = notification.getData();
|
|
65
|
+
const streamPayload = data?.stream;
|
|
66
|
+
const isClicked = data.userInteraction === 1;
|
|
67
|
+
const pushConfig = _StreamVideoRN.StreamVideoRN.getConfig().push;
|
|
68
|
+
if (!streamPayload || !isClicked || !pushConfig) {
|
|
69
|
+
notification.finish(pushNotificationIosLib.FetchResult.NoData);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// listen to foreground notifications
|
|
73
|
+
const result = processNonRingingNotificationStreamPayload(streamPayload);
|
|
74
|
+
if (result) {
|
|
75
|
+
pushConfig.onTapNonRingingCallNotification?.(result.cid, result.type);
|
|
76
|
+
}
|
|
77
|
+
notification.finish(pushNotificationIosLib.FetchResult.NoData);
|
|
78
|
+
}
|
|
103
79
|
|
|
104
80
|
/** Send token to stream */
|
|
105
|
-
exports.setupRemoteNotificationsHandleriOS = setupRemoteNotificationsHandleriOS;
|
|
106
81
|
async function initIosNonVoipToken(client, pushConfig, setUnsubscribeListener) {
|
|
107
82
|
if (_reactNative.Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName || !pushConfig.onTapNonRingingCallNotification) {
|
|
108
83
|
return;
|
|
@@ -139,32 +114,16 @@ async function initIosNonVoipToken(client, pushConfig, setUnsubscribeListener) {
|
|
|
139
114
|
const subscription = expoNotificationsLib.addPushTokenListener(devicePushToken => {
|
|
140
115
|
setDeviceToken(devicePushToken.data);
|
|
141
116
|
});
|
|
142
|
-
const subscriptionForReceive = expoNotificationsLib.addNotificationReceivedListener(event => {
|
|
143
|
-
// listen to foreground notifications
|
|
144
|
-
if (event.request.trigger.type === 'push') {
|
|
145
|
-
const streamPayload = event.request.trigger.payload?.stream;
|
|
146
|
-
processNonRingingNotificationStreamPayload(streamPayload);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
117
|
setUnsubscribeListener(() => {
|
|
150
118
|
subscription.remove();
|
|
151
|
-
subscriptionForReceive.remove();
|
|
152
119
|
});
|
|
153
120
|
} else {
|
|
154
121
|
const pushNotificationIosLib = (0, _libs.getPushNotificationIosLib)();
|
|
155
122
|
pushNotificationIosLib.addEventListener('register', token => {
|
|
156
123
|
setDeviceToken(token);
|
|
157
124
|
});
|
|
158
|
-
pushNotificationIosLib.addEventListener('notification', notification => {
|
|
159
|
-
const data = notification.getData();
|
|
160
|
-
const streamPayload = data?.stream;
|
|
161
|
-
// listen to foreground notifications
|
|
162
|
-
processNonRingingNotificationStreamPayload(streamPayload);
|
|
163
|
-
notification.finish(pushNotificationIosLib.FetchResult.NoData);
|
|
164
|
-
});
|
|
165
125
|
setUnsubscribeListener(() => {
|
|
166
126
|
pushNotificationIosLib.removeEventListener('register');
|
|
167
|
-
pushNotificationIosLib.removeEventListener('notification');
|
|
168
127
|
});
|
|
169
128
|
}
|
|
170
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_rxSubjects","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_rxSubjects","_libs","_videoClient","_pushLogoutCallback","_reactNative2","_StreamVideoRN","lastApnToken","token","userId","processNonRingingNotificationStreamPayload","streamPayload","sender","type","cid","call_cid","pushNonRingingCallData$","next","oniOSExpoNotificationEvent","event","pushConfig","StreamVideoRN","getConfig","push","request","trigger","payload","stream","exports","oniOSNotifeeEvent","Platform","OS","detail","EventType","PRESS","notification","data","result","onTapNonRingingCallNotification","onPushNotificationiOSStreamVideoEvent","pushNotificationIosLib","getPushNotificationIosLib","getData","isClicked","userInteraction","finish","FetchResult","NoData","initIosNonVoipToken","client","setUnsubscribeListener","ios","pushProviderName","setDeviceToken","streamClient","_user","id","setPushLogoutCallback","removeDevice","err","logger","getLogger","push_provider_name","addDevice","isExpo","expoNotificationsLib","getExpoNotificationsLib","getDevicePushTokenAsync","then","devicePushToken","subscription","addPushTokenListener","remove","addEventListener","removeEventListener"],"sourceRoot":"../../../../src","sources":["utils/push/ios.ts"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAMA,IA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IACDc,sBAAsB,CAAC,MAAM;MAC3BoB,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,MAAMhC,sBAAsB,GAAG,IAAAC,+BAAyB,EAAC,CAAC;IAC1DD,sBAAsB,CAACiC,gBAAgB,CAAC,UAAU,EAAGjE,KAAK,IAAK;MAC7D6C,cAAc,CAAC7C,KAAK,CAAC;IACvB,CAAC,CAAC;IACF0C,sBAAsB,CAAC,MAAM;MAC3BV,sBAAsB,CAACkC,mBAAmB,CAAC,UAAU,CAAC;IACxD,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["expoNotificationsLib","require","_e","getExpoNotificationsLib","Error"],"sourceRoot":"../../../../../src","sources":["utils/push/libs/expoNotifications.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["expoNotificationsLib","require","_e","getExpoNotificationsLib","Error"],"sourceRoot":"../../../../../src","sources":["utils/push/libs/expoNotifications.ts"],"mappings":";;;;;;AAMA,IAAIA,oBAAsD;AAE1D,IAAI;EACFA,oBAAoB,GAAGC,OAAO,CAAC,oBAAoB,CAAC;AACtD,CAAC,CAAC,OAAOC,EAAE,EAAE,CAAC;AAEP,SAASC,uBAAuBA,CAAA,EAAG;EACxC,IAAI,CAACH,oBAAoB,EAAE;IACzB,MAAMI,KAAK,CACT,gJACF,CAAC;EACH;EACA,OAAOJ,oBAAoB;AAC7B","ignoreList":[]}
|
|
@@ -14,17 +14,6 @@ Object.keys(_expoNotifications).forEach(function (key) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var _expoTaskManager = require("./expoTaskManager");
|
|
18
|
-
Object.keys(_expoTaskManager).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _expoTaskManager[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _expoTaskManager[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
17
|
var _firebaseMessaging = require("./firebaseMessaging");
|
|
29
18
|
Object.keys(_firebaseMessaging).forEach(function (key) {
|
|
30
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_expoNotifications","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","
|
|
1
|
+
{"version":3,"names":["_expoNotifications","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_firebaseMessaging","_iosPushNotification","_voipPushNotification","_callkeep","_notifee"],"sourceRoot":"../../../../../src","sources":["utils/push/libs/index.ts"],"mappings":";;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,kBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,kBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,kBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,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IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,QAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,QAAA,CAAAT,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pushNotificationIosLib","require","default","_e","getPushNotificationIosLib","Error"],"sourceRoot":"../../../../../src","sources":["utils/push/libs/iosPushNotification.ts"],"mappings":";;;;;;AAGA,IAAIA,sBAA0D;
|
|
1
|
+
{"version":3,"names":["pushNotificationIosLib","require","default","_e","getPushNotificationIosLib","Error"],"sourceRoot":"../../../../../src","sources":["utils/push/libs/iosPushNotification.ts"],"mappings":";;;;;;AAGA,IAAIA,sBAA0D;AAM9D,IAAI;EACFA,sBAAsB,GACpBC,OAAO,CAAC,+CAA+C,CAAC,CAACC,OAAO;AACpE,CAAC,CAAC,OAAOC,EAAE,EAAE,CAAC;AAEP,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,IAAI,CAACJ,sBAAsB,EAAE;IAC3B,MAAMK,KAAK,CACT,0NACF,CAAC;EACH;EACA,OAAOL,sBAAsB;AAC/B","ignoreList":[]}
|
|
@@ -3,155 +3,34 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (rejected_by[created_by_id]) {
|
|
30
|
-
// call was cancelled by the caller
|
|
31
|
-
mustEndCall = true;
|
|
32
|
-
callkeepReason = 2;
|
|
33
|
-
}
|
|
34
|
-
} else if (receiver_id && rejected_by) {
|
|
35
|
-
if (rejected_by[receiver_id]) {
|
|
36
|
-
// call was rejected by the receiver in some other device
|
|
37
|
-
mustEndCall = true;
|
|
38
|
-
callkeepReason = 5;
|
|
39
|
-
}
|
|
40
|
-
} else if (receiver_id && accepted_by) {
|
|
41
|
-
if (accepted_by[receiver_id]) {
|
|
42
|
-
// call was accepted by the receiver in some other device
|
|
43
|
-
mustEndCall = true;
|
|
44
|
-
callkeepReason = 4;
|
|
45
|
-
}
|
|
6
|
+
exports.isExpoNotificationStreamVideoEvent = isExpoNotificationStreamVideoEvent;
|
|
7
|
+
exports.isFirebaseStreamVideoMessage = isFirebaseStreamVideoMessage;
|
|
8
|
+
exports.isNotifeeStreamVideoEvent = isNotifeeStreamVideoEvent;
|
|
9
|
+
exports.isPushNotificationiOSStreamVideoEvent = isPushNotificationiOSStreamVideoEvent;
|
|
10
|
+
function isFirebaseStreamVideoMessage(message) {
|
|
11
|
+
return message.data?.sender === 'stream.video';
|
|
12
|
+
}
|
|
13
|
+
function isNotifeeStreamVideoEvent(event) {
|
|
14
|
+
const {
|
|
15
|
+
detail
|
|
16
|
+
} = event;
|
|
17
|
+
const {
|
|
18
|
+
notification
|
|
19
|
+
} = detail;
|
|
20
|
+
return notification?.data?.sender === 'stream.video';
|
|
21
|
+
}
|
|
22
|
+
function isExpoNotificationStreamVideoEvent(event) {
|
|
23
|
+
if (event.request.trigger.type === 'push') {
|
|
24
|
+
// iOS
|
|
25
|
+
const streamPayload = event.request.trigger.payload?.stream;
|
|
26
|
+
// Android
|
|
27
|
+
const remoteMessageData = event.request.trigger.remoteMessage?.data;
|
|
28
|
+
return streamPayload?.sender === 'stream.video' || remoteMessageData?.sender === 'stream.video';
|
|
46
29
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/* An action for the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
|
|
54
|
-
1. we need to create a new client and connect the user to decline the call
|
|
55
|
-
2. this is because the app is in background state and we don't have a client to get the call and do an action
|
|
56
|
-
*/
|
|
57
|
-
exports.shouldCallBeEnded = shouldCallBeEnded;
|
|
58
|
-
const processCallFromPushInBackground = async (pushConfig, call_cid, action) => {
|
|
59
|
-
let videoClient;
|
|
60
|
-
try {
|
|
61
|
-
videoClient = await pushConfig.createStreamVideoClient();
|
|
62
|
-
if (!videoClient) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
} catch (e) {
|
|
66
|
-
const logger = (0, _videoClient.getLogger)(['processCallFromPushInBackground']);
|
|
67
|
-
logger('error', 'failed to create video client', e);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
await processCallFromPush(videoClient, call_cid, action, pushConfig);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* This function is used process the call from push notifications due to incoming call
|
|
75
|
-
* It does the following steps:
|
|
76
|
-
* 1. Get the call from the client if present or create a new call
|
|
77
|
-
* 2. Fetch the latest state of the call from the server if its not already in ringing state
|
|
78
|
-
* 3. Join or leave the call based on the user's action.
|
|
79
|
-
*/
|
|
80
|
-
exports.processCallFromPushInBackground = processCallFromPushInBackground;
|
|
81
|
-
const processCallFromPush = async (client, call_cid, action, pushConfig) => {
|
|
82
|
-
let callFromPush;
|
|
83
|
-
try {
|
|
84
|
-
callFromPush = await client.onRingingCall(call_cid);
|
|
85
|
-
} catch (e) {
|
|
86
|
-
const logger = (0, _videoClient.getLogger)(['processCallFromPush']);
|
|
87
|
-
logger('error', 'failed to fetch call from push notification', e);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
// note: when action was pressed or delivered, we dont need to do anything as the only thing is to do is to get the call which adds it to the client
|
|
91
|
-
try {
|
|
92
|
-
if (action === 'accept') {
|
|
93
|
-
if (pushConfig.publishOptions) {
|
|
94
|
-
callFromPush.updatePublishOptions(pushConfig.publishOptions);
|
|
95
|
-
}
|
|
96
|
-
await callFromPush.join();
|
|
97
|
-
} else if (action === 'decline') {
|
|
98
|
-
await callFromPush.leave({
|
|
99
|
-
reject: true
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
} catch (e) {
|
|
103
|
-
const logger = (0, _videoClient.getLogger)(['processCallFromPush']);
|
|
104
|
-
logger('error', `failed to process ${action} call from push notification`, e);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* This function is used process the call from push notifications due to non ringing calls
|
|
110
|
-
* It does the following steps:
|
|
111
|
-
* 1. Get the call from the client if present or create a new call
|
|
112
|
-
* 2. Fetch the latest state of the call from the server if its not already in ringing state
|
|
113
|
-
* 3. Call all the callbacks to inform the app about the call
|
|
114
|
-
*/
|
|
115
|
-
exports.processCallFromPush = processCallFromPush;
|
|
116
|
-
const processNonIncomingCallFromPush = async (client, call_cid, nonRingingNotificationType) => {
|
|
117
|
-
let callFromPush;
|
|
118
|
-
try {
|
|
119
|
-
const _callFromPush = client.state.calls.find(c => c.cid === call_cid);
|
|
120
|
-
if (_callFromPush) {
|
|
121
|
-
callFromPush = _callFromPush;
|
|
122
|
-
} else {
|
|
123
|
-
// if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
|
|
124
|
-
const [callType, callId] = call_cid.split(':');
|
|
125
|
-
callFromPush = client.call(callType, callId);
|
|
126
|
-
await callFromPush.get();
|
|
127
|
-
}
|
|
128
|
-
} catch (e) {
|
|
129
|
-
const logger = (0, _videoClient.getLogger)(['processNonIncomingCallFromPush']);
|
|
130
|
-
logger('error', 'failed to fetch call from push notification', e);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
(0, _newNotificationCallbacks.onNewCallNotification)(callFromPush, nonRingingNotificationType);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* This function is used to clear all the push related WS subscriptions
|
|
138
|
-
* note: events are subscribed in push for accept/decline through WS
|
|
139
|
-
*/
|
|
140
|
-
exports.processNonIncomingCallFromPush = processNonIncomingCallFromPush;
|
|
141
|
-
const clearPushWSEventSubscriptions = () => {
|
|
142
|
-
const unsubscriptionCallbacks = _videoClient.RxUtils.getCurrentValue(_rxSubjects.pushUnsubscriptionCallbacks$);
|
|
143
|
-
if (unsubscriptionCallbacks) {
|
|
144
|
-
unsubscriptionCallbacks.forEach(cb => cb());
|
|
145
|
-
}
|
|
146
|
-
_rxSubjects.pushUnsubscriptionCallbacks$.next(undefined);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* This ref is used to check if the push WS subscriptions can be added
|
|
151
|
-
* It is used to avoid adding the push WS subscriptions when the client is connected to WS in the foreground
|
|
152
|
-
*/
|
|
153
|
-
exports.clearPushWSEventSubscriptions = clearPushWSEventSubscriptions;
|
|
154
|
-
const canAddPushWSSubscriptionsRef = exports.canAddPushWSSubscriptionsRef = {
|
|
155
|
-
current: true
|
|
156
|
-
};
|
|
30
|
+
}
|
|
31
|
+
function isPushNotificationiOSStreamVideoEvent(notification) {
|
|
32
|
+
const data = notification.getData();
|
|
33
|
+
const streamPayload = data?.stream;
|
|
34
|
+
return streamPayload?.sender === 'stream.video';
|
|
35
|
+
}
|
|
157
36
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isFirebaseStreamVideoMessage","message","data","sender","isNotifeeStreamVideoEvent","event","detail","notification","isExpoNotificationStreamVideoEvent","request","trigger","type","streamPayload","payload","stream","remoteMessageData","remoteMessage","isPushNotificationiOSStreamVideoEvent","getData"],"sourceRoot":"../../../../src","sources":["utils/push/utils.ts"],"mappings":";;;;;;;;;AAcO,SAASA,4BAA4BA,CAC1CC,OAA6C,EAC7C;EACA,OAAOA,OAAO,CAACC,IAAI,EAAEC,MAAM,KAAK,cAAc;AAChD;AAEO,SAASC,yBAAyBA,CAACC,KAAY,EAAE;EACtD,MAAM;IAAEC;EAAO,CAAC,GAAGD,KAAK;EACxB,MAAM;IAAEE;EAAa,CAAC,GAAGD,MAAM;EAC/B,OAAOC,YAAY,EAAEL,IAAI,EAAEC,MAAM,KAAK,cAAc;AACtD;AAEO,SAASK,kCAAkCA,CAACH,KAAuB,EAAE;EAC1E,IAAIA,KAAK,CAACI,OAAO,CAACC,OAAO,CAACC,IAAI,KAAK,MAAM,EAAE;IACzC;IACA,MAAMC,aAAa,GAAGP,KAAK,CAACI,OAAO,CAACC,OAAO,CAACG,OAAO,EAC/CC,MAA2B;IAC/B;IACA,MAAMC,iBAAiB,GAAGV,KAAK,CAACI,OAAO,CAACC,OAAO,CAACM,aAAa,EAAEd,IAAI;IACnE,OACEU,aAAa,EAAET,MAAM,KAAK,cAAc,IACxCY,iBAAiB,EAAEZ,MAAM,KAAK,cAAc;EAEhD;AACF;AAEO,SAASc,qCAAqCA,CACnDV,YAAqC,EACrC;EACA,MAAML,IAAI,GAAGK,YAAY,CAACW,OAAO,CAAC,CAAC;EACnC,MAAMN,aAAa,GAAGV,IAAI,EAAEY,MAA2B;EACvD,OAAOF,aAAa,EAAET,MAAM,KAAK,cAAc;AACjD","ignoreList":[]}
|
package/dist/commonjs/version.js
CHANGED