Skip to content

Commit

Permalink
Integration dynamic link on android mobile (#1951)
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored Jul 17, 2024
1 parent 827e0a1 commit 282c411
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="twake.chat"
android:host="openApp"/>
</intent-filter>
</activity>

<activity android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
Expand Down
10 changes: 10 additions & 0 deletions lib/pages/chat_list/receive_sharing_intent_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {

StreamSubscription? intentUriStreamSubscription;

bool _intentOpenApp(String text) {
return text.contains('twake.chat://openApp');
}

void _processIncomingSharedFiles(List<SharedMediaFile> files) {
if (files.isEmpty) return;
matrixState.shareContentList = files
Expand All @@ -36,6 +40,9 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {

void _processIncomingSharedText(String? text) {
if (text == null) return;
if (_intentOpenApp(text)) {
return;
}
if (text.toLowerCase().startsWith(AppConfig.deepLinkPrefix) ||
text.toLowerCase().startsWith(AppConfig.inviteLinkPrefix) ||
(text.toLowerCase().startsWith(AppConfig.schemePrefix) &&
Expand All @@ -52,6 +59,9 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
void _processIncomingUris(String? text) async {
Logs().d("ReceiveSharingIntentMixin: _processIncomingUris: $text");
if (text == null) return;
if (_intentOpenApp(text)) {
return;
}
TwakeApp.router.go('/share');
WidgetsBinding.instance.addPostFrameCallback((_) {
UrlLauncher(context, url: text).openMatrixToUrl();
Expand Down

0 comments on commit 282c411

Please sign in to comment.