diff --git a/lib/src/utils/share/share_post.dart b/lib/src/utils/share/share_post.dart index bc239b3..7280b0e 100644 --- a/lib/src/utils/share/share_post.dart +++ b/lib/src/utils/share/share_post.dart @@ -14,16 +14,16 @@ class SharePost { static String userId = prodFlag ? CredsProd.botId : CredsDev.botId; static String apiKey = prodFlag ? CredsProd.apiKey : CredsDev.apiKey; // TODO: Add domain to your application - String domain = 'suraasalearn://www.suraasa.com'; + String domain = 'https://www.suraasa.com'; // fetches the domain given by client at time of initialization of Feed // below function creates a link from domain and post id String createLink(String postId) { int length = domain.length; if (domain[length - 1] == '/') { - return "${domain}post?post_id=$postId"; + return "${domain}community/post?post_id=$postId"; } else { - return "$domain/post?post_id=$postId"; + return "$domain/community/post?post_id=$postId"; } } @@ -45,17 +45,21 @@ class SharePost { } } - Future handlePostDeepLink(DeepLinkRequest request, BuildContext context) async { + Future handlePostDeepLink( + DeepLinkRequest request, + GlobalKey navigatorKey, + ) async { List secondPathSegment = request.link.split('post_id='); if (secondPathSegment.length > 1 && secondPathSegment[1] != null) { String postId = secondPathSegment[1]; - await locator().initiateUser((InitiateUserRequestBuilder() - ..apiKey(request.apiKey) - ..userId(request.userUniqueId) - ..userName(request.userName)) - .build()); + await locator() + .initiateUser((InitiateUserRequestBuilder() + ..apiKey(request.apiKey) + ..userId(request.userUniqueId) + ..userName(request.userName)) + .build()); - Navigator.of(context).push( + navigatorKey.currentState!.push( MaterialPageRoute( builder: (context) => PostDetailScreen(postId: postId), ), @@ -73,13 +77,15 @@ class SharePost { } } - Future parseDeepLink(DeepLinkRequest request, BuildContext context) async { - if (Uri.parse(request.link).isAbsolute) { - final firstPathSegment = getFirstPathSegment(request.link); - if (firstPathSegment == "post") { - return handlePostDeepLink(request, context); + Future parseDeepLink( + DeepLinkRequest request, GlobalKey navigatorKey) async { + final link = Uri.parse(request.link); + if (link.isAbsolute) { + if (link.path == '/community/post') { + return handlePostDeepLink(request, navigatorKey); } - return DeepLinkResponse(success: false, errorMessage: 'URI not supported'); + return DeepLinkResponse( + success: false, errorMessage: 'URI not supported'); } else { return DeepLinkResponse( success: false,