forked from eatvio/eatvio_app
feat: try push handling
This commit is contained in:
@@ -55,32 +55,19 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" />
|
||||
|
||||
<!-- Main domains -->
|
||||
<data android:host="eatvio.ru" />
|
||||
<data android:host="www.eatvio.ru" />
|
||||
<data android:host="eatvio.com" />
|
||||
<data android:host="www.eatvio.com" />
|
||||
|
||||
<data android:pathPattern="/ru/recipe/.*" />
|
||||
<data android:pathPattern="/en/recipe/.*" />
|
||||
<!-- Development/Subdomains -->
|
||||
<data android:host="*.eatvio.ru" />
|
||||
<data android:host="*.eatvio.com" />
|
||||
|
||||
<data android:pathPattern="/ru/blog_post/.*" />
|
||||
<data android:pathPattern="/en/blog_post/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/diet/.*" />
|
||||
<data android:pathPattern="/en/diet/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/plan/.*" />
|
||||
<data android:pathPattern="/en/plan/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/chat/.*" />
|
||||
<data android:pathPattern="/en/chat/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/chat" />
|
||||
<data android:pathPattern="/en/chat" />
|
||||
|
||||
<data android:pathPattern="/ru/profile/.*" />
|
||||
<data android:pathPattern="/en/profile/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/diary/.*" />
|
||||
<data android:pathPattern="/en/diary/.*" />
|
||||
<!-- Simplify patterns to allow navigation within the app for all matching hosts -->
|
||||
<data android:pathPattern="/.*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
|
||||
@@ -49,6 +49,7 @@ class AppRouter {
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
|
||||
// Обработка api ссылок (например, из пушей чата)
|
||||
if (segments.length >= 4 &&
|
||||
segments[0] == 'api' &&
|
||||
segments[1] == 'v2' &&
|
||||
@@ -59,33 +60,32 @@ class AppRouter {
|
||||
return RouteConstants.chatSelectScreen;
|
||||
}
|
||||
|
||||
if (segments[0] != 'ru' && segments[0] != 'en') {
|
||||
developer.log('Invalid language segment: ${segments[0]}, redirecting to feed', name: 'AppRouter');
|
||||
// Определяем, есть ли в начале сегмент языка (ru/en). Если есть — пропускаем его.
|
||||
int startIndex = 0;
|
||||
if (segments[0] == 'ru' || segments[0] == 'en') {
|
||||
startIndex = 1;
|
||||
} else {
|
||||
developer.log('Deep link without language segment: ${segments[0]}', name: 'AppRouter');
|
||||
}
|
||||
|
||||
final effectiveSegments = segments.sublist(startIndex);
|
||||
if (effectiveSegments.isEmpty) {
|
||||
developer.log('No effective segments after language check, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
|
||||
if (segments.length == 4) {
|
||||
final type = segments[1];
|
||||
final type = effectiveSegments[0];
|
||||
|
||||
if (type == 'diary') {
|
||||
developer.log('Deep link: diary, redirecting to diary-screen', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.diaryScreen;
|
||||
}
|
||||
if (type == 'consultations' && segments[2] == 'status') {
|
||||
final consultationId = segments[3];
|
||||
if (effectiveSegments.length == 3 && type == 'consultations' && effectiveSegments[1] == 'status') {
|
||||
final consultationId = effectiveSegments[2];
|
||||
developer.log('Deep link: consultations/status/$consultationId', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '${RouteConstants.consultationsScreen}?id=$consultationId';
|
||||
}
|
||||
|
||||
developer.log('Unknown deep link type for 4 segments: $type, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
} else if (segments.length == 3) {
|
||||
final type = segments[1];
|
||||
final contentIdentifier = segments[2];
|
||||
if (effectiveSegments.length == 2) {
|
||||
final contentIdentifier = effectiveSegments[1];
|
||||
|
||||
switch (type) {
|
||||
case 'recipe':
|
||||
@@ -100,7 +100,8 @@ class AppRouter {
|
||||
developer.log('Deep link: plan/$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '/about-plan-screen?slug=$contentIdentifier';
|
||||
case 'diet': {
|
||||
case 'diet':
|
||||
{
|
||||
final dietId = int.tryParse(contentIdentifier);
|
||||
if (dietId != null) {
|
||||
developer.log('Deep link: diet/id=$dietId', name: 'AppRouter');
|
||||
@@ -116,15 +117,9 @@ class AppRouter {
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.chatSelectScreen;
|
||||
case 'profile':
|
||||
// В диплинке передан slug — открываем профиль пользователя по slug.
|
||||
developer.log('Deep link: profile/$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '/profile-screen?slug=$contentIdentifier';
|
||||
case 'badge':
|
||||
// В badge нет slug, открываем вкладку «Мой профиль».
|
||||
developer.log('Deep link: badge → my-profile tab', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.myProfileScreen;
|
||||
case 'diary':
|
||||
developer.log('Deep link: diary/$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
@@ -133,14 +128,10 @@ class AppRouter {
|
||||
developer.log('Deep link: consultant_diary_comment/$contentIdentifier → diary', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.diaryScreen;
|
||||
default:
|
||||
developer.log('Unknown deep link type: $type, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
} else if (segments.length == 2) {
|
||||
final type = segments[1];
|
||||
}
|
||||
|
||||
if (effectiveSegments.length == 1) {
|
||||
if (type == 'chat') {
|
||||
developer.log('Deep link: chat', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
@@ -151,13 +142,14 @@ class AppRouter {
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.diaryScreen;
|
||||
}
|
||||
|
||||
developer.log('Unknown deep link type for 2 segments: $type, redirecting to feed', name: 'AppRouter');
|
||||
if (type == 'badge') {
|
||||
developer.log('Deep link: badge → my-profile tab', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
return RouteConstants.myProfileScreen;
|
||||
}
|
||||
}
|
||||
|
||||
developer.log('Unknown deep link format: ${segments.length} segments, redirecting to feed', name: 'AppRouter');
|
||||
developer.log('Unknown deep link format: ${effectiveSegments.length} effective segments, type=$type, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,11 @@ class PushNavigationHandler {
|
||||
}
|
||||
|
||||
static void _handleMessageInternal(RemoteMessage message, {required String source}) {
|
||||
developer.log(
|
||||
'PushNavigationHandler: received message. data=${message.data}, notification=${message.notification?.title}, source=$source',
|
||||
name: 'PushNavigationHandler',
|
||||
);
|
||||
|
||||
final data = message.data;
|
||||
|
||||
// Пытаемся взять URL из action_url или action (бэкенд шлёт и то и другое)
|
||||
@@ -80,7 +85,7 @@ class PushNavigationHandler {
|
||||
|
||||
if (rawUrl != null && rawUrl.isNotEmpty) {
|
||||
developer.log(
|
||||
'PushNavigationHandler: navigating by url=$rawUrl, source=$source',
|
||||
'PushNavigationHandler: manual navigation by url=$rawUrl, source=$source',
|
||||
name: 'PushNavigationHandler',
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: eatvio_app
|
||||
description: A new Flutter project.
|
||||
version: 1.3.18+98
|
||||
version: 1.3.19+99
|
||||
publish_to: 'none'
|
||||
|
||||
environment:
|
||||
|
||||
Reference in New Issue
Block a user