Synerise / synerise-flutter-sdk

Synerise SDK plugin for Flutter
Apache License 2.0
5 stars 0 forks source link

Deeplink with scheme https is automatically opened in browser instead of app #6

Closed tomkadziolka closed 3 months ago

tomkadziolka commented 1 year ago

Version: 0.7.0

During experiments with the SDK I have noticed that even if the action for simple push is selected as "Deep linking", the app on Android is opening browser with given deeplink.

We would continue to use the deeplinks that start with https:// and browser can be automatically launched, but for the action type: "Open url".

konned commented 1 year ago

Can you please provide your universal linking implementation? AndroidManifest.xml and main.dart

tomkadziolka commented 1 year ago

This is our AndroidManifest.xml (anonymous)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.domain.project">
    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
        <intent>
            <action android:name="android.intent.action.DIAL" />
            <data android:scheme="tel" />
        </intent>
        <intent>
            <action android:name="android.intent.action.SENDTO" />
            <data android:scheme="mailto" />
        </intent>
    </queries>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" />

    <application
        android:name="${applicationName}"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="false"
        android:networkSecurityConfig="@xml/network_security_config"
        android:fullBackupContent="@xml/backup_rules"
        tools:replace="android:fullBackupContent">

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

        <meta-data 
            android:name="com.google.android.geo.API_KEY"
            android:value="XXX"/>

        <meta-data 
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/notification_icon" />

        <meta-data
            android:name="com.synerise.sdk.messaging.notification_icon"
            android:resource="@drawable/notification_icon" />

        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </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:pathPrefix="/banner"
                    android:host="domain.pl"
                    android:scheme="https"/>
                <data
                    android:pathPrefix="/marketplace"
                    android:host="domain.pl"
                    android:scheme="https"/>
                <data
                    android:pathPrefix="/partner"
                    android:host="domain.pl"
                    android:scheme="https"/>
                <data
                    android:pathPrefix="/profile"
                    android:host="domain.pl"
                    android:scheme="https"/>
                <data
                    android:path="/"
                    android:host="domain.pl"
                    android:scheme="https"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

And we don't have simple push configuration in main, I will try to add more details to reproduction

konned commented 1 year ago

Try to add autoVerify to your intent-filter according to https://docs.flutter.dev/cookbook/navigation/set-up-app-links

tomkadziolka commented 1 year ago

I tried and autoVerify doesn't seem to resolve the problem, earlier without it we didn't have this problem when sending non-Synerise pushes via Firebase console.

Message config: image

On iOS when I click on the Synerise notification, we immediately receive an action from: FirebaseMessaging.onMessageOpenedApp

On Android FirebaseMessaging.onMessageOpenedApp is not called then.

I reproduced this behaviour in your's example app:

https://github.com/Synerise/synerise-flutter-sdk/assets/124564649/a92c9d6a-9952-481b-b8b2-d5af36ee8452

konned commented 9 months ago

On android behaviour is slightly different. From version 0.8.0 there is possibility to handle deepLink manually inside callback in dart. Please try this way. https://hub.synerise.com//developers/mobile-sdk/campaigns/action-handling/

Additionally, Can you send me your logcat when you click on notification? There should be an error showing that there is no activity to handle intent with your link.

tomkad99 commented 4 months ago

@konned Thanks for your message.

We will try now to integrate with newest version in our product

tomkad99 commented 3 months ago

@konned After update to 1.1.1 we are able to handle links and deeplinks properly.

This is can be closed :)