forked from eatvio/eatvio_app
feat(video_calls): ios calle mic fix, infinite loading after accepting call on an oppened app fix, incaming call declining after declining on a different device
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'package:eatvio_app/core/app_config.dart';
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:eatvio_app/core/device/device_hw_id_provider.dart';
|
||||
import 'package:eatvio_app/core/notifications/notification_permission_requester.dart';
|
||||
import 'package:eatvio_app/core/push/hms_client_error.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
@@ -44,15 +45,16 @@ class FirebaseApi {
|
||||
Future<void> registerAnonymousPushToken() async {
|
||||
try {
|
||||
await _requestNotificationPermission();
|
||||
final deviceInfo = DeviceInfoPlugin();
|
||||
final credentials = await _resolvePushCredentials();
|
||||
final token = credentials.token;
|
||||
if (token == null || token.isEmpty) return;
|
||||
final hwId = await DeviceHwIdProvider.current();
|
||||
if (hwId == null || hwId.length < 8) return;
|
||||
await sl<Dio>().post(
|
||||
'/api/anonymous_token',
|
||||
data: {
|
||||
'platform': credentials.platform,
|
||||
'hw_id': Platform.isIOS ? (await deviceInfo.iosInfo).identifierForVendor : (await deviceInfo.androidInfo).id,
|
||||
'hw_id': hwId,
|
||||
'token': token,
|
||||
},
|
||||
).timeout(
|
||||
@@ -72,23 +74,38 @@ class FirebaseApi {
|
||||
if (!await TokenStorage.haveTokenInStorage()) return;
|
||||
try {
|
||||
await _requestNotificationPermission();
|
||||
final deviceInfo = DeviceInfoPlugin();
|
||||
final credentials = await _resolvePushCredentials();
|
||||
final token = credentials.token;
|
||||
if (token != null && token.isNotEmpty) {
|
||||
await sl<Dio>().post(
|
||||
'/api/profile/notification/token/register',
|
||||
data: {
|
||||
'platform': credentials.platform,
|
||||
'hw_id': Platform.isIOS ? (await deviceInfo.iosInfo).identifierForVendor : (await deviceInfo.androidInfo).id,
|
||||
'token': token,
|
||||
},
|
||||
).timeout(
|
||||
const Duration(seconds: 10),
|
||||
onTimeout: () {
|
||||
throw TimeoutException('registerPushToken timeout');
|
||||
},
|
||||
);
|
||||
final hwId = await DeviceHwIdProvider.current();
|
||||
final reregisterAndroid =
|
||||
await DeviceHwIdProvider.androidTokenNeedsReregister();
|
||||
if (token != null &&
|
||||
token.isNotEmpty &&
|
||||
hwId != null &&
|
||||
hwId.length >= 8) {
|
||||
if (reregisterAndroid) {
|
||||
try {
|
||||
await unregisterPushToken();
|
||||
} catch (_) {}
|
||||
}
|
||||
await sl<Dio>()
|
||||
.post(
|
||||
'/api/profile/notification/token/register',
|
||||
data: {
|
||||
'platform': credentials.platform,
|
||||
'hw_id': hwId,
|
||||
'token': token,
|
||||
},
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: 10),
|
||||
onTimeout: () {
|
||||
throw TimeoutException('registerPushToken timeout');
|
||||
},
|
||||
);
|
||||
if (reregisterAndroid) {
|
||||
await DeviceHwIdProvider.markAndroidTokenReregistered();
|
||||
}
|
||||
}
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
@@ -145,12 +162,13 @@ class FirebaseApi {
|
||||
final token = (await FlutterCallkitIncoming.getDevicePushTokenVoIP())?.trim();
|
||||
if (token == null || token.isEmpty) return;
|
||||
|
||||
final deviceInfo = DeviceInfoPlugin();
|
||||
final hwId = await DeviceHwIdProvider.current();
|
||||
if (hwId == null || hwId.length < 8) return;
|
||||
await sl<Dio>().post(
|
||||
'/api/profile/notification/token/voip/register',
|
||||
data: {
|
||||
'platform': 'ios',
|
||||
'hw_id': (await deviceInfo.iosInfo).identifierForVendor,
|
||||
'hw_id': hwId,
|
||||
'token': token,
|
||||
},
|
||||
).timeout(
|
||||
|
||||
Reference in New Issue
Block a user