chandrabezzo / flutter_dynamic_icon_plus

MIT License
5 stars 3 forks source link

When clicking push notification does'nt open app after changing app icon with dynamic_icon_plus #5

Open mberktas opened 2 months ago

mberktas commented 2 months ago

Hi,

Push notifications open the app before the dynamic icon changes. However, after changing the dynamic icon, push notification does not open the app on Android. There is no problem on iOS.

Do you have any information about what may cause this problem?

Packages onesignal_flutter: ^5.1.6 flutter_dynamic_icon_plus: ^1.2.1

Version Flutter 3.19.6

Android Manifest

<activity android:name=".MainActivity" android:exported="true" android:enabled="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"/>
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>
</activity>

  <service
          android:name="com.solusibejo.flutter_dynamic_icon_plus.FlutterDynamicIconPlusService"
          android:stopWithTask="false"/>

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

<activity-alias
    android:label="@string/app_name"
    android:icon="@mipmap/ic_birthday"
    android:roundIcon="@mipmap/ic_birthday"
    android:name=".birthday"
    android:exported="true"
    android:enabled="false"
    android:targetActivity="${applicationId}.MainActivity">

    <meta-data
        android:name="io.flutter.embedding.android.NormalTheme"
        android:resource="@style/NormalTheme"
        />

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

</activity-alias>

<activity-alias
    android:label="@string/app_name"
    android:icon="@mipmap/ic_mourning"
    android:roundIcon="@mipmap/ic_mourning"
    android:name=".mourning"
    android:exported="true"
    android:enabled="false"
    android:targetActivity="${applicationId}.MainActivity">

    <meta-data
        android:name="io.flutter.embedding.android.NormalTheme"
        android:resource="@style/NormalTheme"
        />

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

</activity-alias>

<activity-alias
    android:label="@string/app_name"
    android:icon="@mipmap/ic_year"
    android:roundIcon="@mipmap/ic_year"
    android:name=".year"
    android:exported="true"
    android:enabled="false"
    android:targetActivity="${applicationId}.MainActivity">

    <meta-data
        android:name="io.flutter.embedding.android.NormalTheme"
        android:resource="@style/NormalTheme"
        />

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

</activity-alias>

<activity-alias
    android:label="@string/app_name"
    android:icon="@mipmap/ic_remembrance"
    android:roundIcon="@mipmap/ic_remembrance"
    android:name=".remembrance"
    android:exported="true"
    android:enabled="false"
    android:targetActivity="${applicationId}.MainActivity">

    <meta-data
        android:name="io.flutter.embedding.android.NormalTheme"
        android:resource="@style/NormalTheme"
        />

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

</activity-alias>
chandrabezzo commented 2 months ago

Hi @mberktas thanks for the report, have you try with just add these code in the activity-alias only?

<intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
mberktas commented 2 months ago

Hi @chandrabezzo ,

Yes, I tried. Actually, it worked.

But there is a problem when building; I get a "package identifier or launch activity not found." error. However, if I cache build activity with intent-filter, and then delete intent-filter, the dynamic icon feature and push notification work perfectly.

However, when I use flutter clean (clean build cache), the issue occurs again."