havesource / cordova-plugin-push

Register and receive push notifications
MIT License
144 stars 276 forks source link

Strange AndroidManifest.xml problem causing notifications to stop working #195

Open imperyal opened 1 year ago

imperyal commented 1 year ago

Bug Report

The AndroidManifest.xml gets progressively clipped of all com.adobe.phonegap.push settings on each build. After some builds no settings remain and the notifications no longer reach the device.

Expected Behaviour

The initial state of the AndroidManifest.xml should be kept.

Actual Behaviour

Settings related the this plugin are progressively removed from the AndroidManifest.xml on each build.

Reproduce Scenario (including but not limited to)

Build the app multiple times.

Steps to Reproduce

Remove the Android platform and add it again. Then do some builds using run and build.

cordova info Printout

Cordova Packages:

    cli: 11.0.0
        common: 4.0.2
        create: 4.0.0
        lib: 11.0.0
            common: 4.0.2
            fetch: 3.0.1
            serve: 4.0.0

Project Installed Platforms:

    android: 10.1.2
    browser: 6.0.0
    ios: 6.2.0

Project Installed Plugins:

    @havesource/cordova-plugin-push: 3.0.1
    cordova-plugin-device: 2.1.0
    cordova-plugin-dialogs: 2.0.2
    cordova-plugin-email-composer: 0.10.0
    cordova-plugin-globalization: 1.11.0
    cordova-plugin-inappbrowser: 5.0.0
    cordova-plugin-network-information: 3.0.0
    cordova-plugin-splashscreen: 6.0.1
    cordova-plugin-statusbar: 3.0.0
    cordova-support-google-services: 1.4.1

Environment:

    OS: Microsoft Windows 11 Pro 10.0.22000 (22000) (Windows 10.0.22000) x64
    Node: v16.15.1
    npm: 8.11.0

android Environment:

    android:
ERROR: Command failed with exit code 1: avdmanager list target
'avdmanager' is not recognized as an internal or external command,
operable program or batch file.

ios Environment:

    xcodebuild:
ERROR: Command failed with exit code 1: xcodebuild -version
'xcodebuild' is not recognized as an internal or external command,
operable program or batch file.

Project Setting Files:

    config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="pt.dcs.horarios" version="2022.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
    <name>DCS Horários</name>
    <description>Aplicação complementar à aplicação DCS-Horários</description>
    <author email="dcs@dcs.pt" href="https://www.dcs.pt">DCS, Lda.</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="permissions" value="none" />
    <preference name="android-windowSoftInputMode" value="stateAlwaysHidden|adjustPan" />
    <preference name="android-installLocation" value="auto" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <!-- <preference name="StatusBarOverlaysWebView" value="false" /> -->
    <preference name="orientation" value="portrait" />
    <preference name="target-device" value="handset" />
    <preference name="deployment-target" value="11.0" />
    <preference name="fullscreen" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="21" />
    <preference name="android-targetSdkVersion" value="31" />
    <platform name="android">
        <!-- <preference name="GradlePluginGoogleServicesEnabled" value="true" /> -->
        <!-- <preference name="GradlePluginGoogleServicesVersion" value="4.2.0" /> -->
        <preference name="AndroidXEnabled" value="true" />
        <preference name="StatusBarOverlaysWebView" value="false" />
        <preference name="AndroidInsecureFileModeEnabled" value="true" />
        <allow-intent href="market:*" />
        <!--
        <config-file parent="./application" target="AndroidManifest.xml">
            <activity android:name="com.adobe.phonegap.push.PushHandlerActivity" android:exported="true" android:permission="${applicationId}.permission.PushHandlerActivity"/>
            <receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler"/>
            <receiver android:name="com.adobe.phonegap.push.PushDismissedHandler"/>
            <service android:name="com.adobe.phonegap.push.FCMService">
                <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
                </intent-filter>
            </service>
            <service android:name="com.adobe.phonegap.push.PushInstanceIDListenerService">
                <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                </intent-filter>
            </service>
        </config-file>
        -->
        <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:usesCleartextTraffic="true" />
            <application android:networkSecurityConfig="@xml/network_security_config" />
            <application android:allowBackup="false" />
            <application android:fullBackupContent="false" />
        </edit-config>
        <resource-file src="network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
        <resource-file src="google-services.json"        target="/app/google-services.json" />
        <!--
        <splash density="hdpi" src="www/res/screen/android/splash-port-hdpi.png" />
        <splash density="port-hdpi" src="www/res/screen/android/splash-port-hdpi.png" />
        <splash density="ldpi" src="www/res/screen/android/splash-port-ldpi.png" />
        <splash density="port-ldpi" src="www/res/screen/android/splash-port-ldpi.png" />
        <splash density="mdpi" src="www/res/screen/android/splash-port-mdpi.png" />
        <splash density="port-mdpi" src="www/res/screen/android/splash-port-mdpi.png" />
        <splash density="xhdpi" src="www/res/screen/android/splash-port-xhdpi.png" />
        <splash density="port-xhdpi" src="www/res/screen/android/splash-port-xhdpi.png" />
        -->
        <icon density="ldpi" src="www/res/icon/android/icon-36-ldpi.png" />
        <icon density="mdpi" src="www/res/icon/android/icon-48-mdpi.png" />
        <icon density="hdpi" src="www/res/icon/android/icon-72-hdpi.png" />
        <icon density="xhdpi" src="www/res/icon/android/icon-96-xhdpi.png" />
        <icon density="xxhdpi" src="www/res/icon/android/icon-144-xxhdpi.png" />
        <icon density="xxxhdpi" src="www/res/icon/android/icon-192-xxxhdpi.png" />
    </platform>
    <platform name="ios">
        <preference name="StatusBarOverlaysWebView" value="true" />
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <resource-file src="google-services.json" target="google-services.json" />

        <splash src="www/res/screen/ios/Default@2x~universal~anyany.png" />

        <icon src="www/res/icon/ios/icon.png"            width="1024" height="1024" />   <!-- App Store  -->
        <icon src="www/res/icon/ios/icon-60-3x.png"      width="180"  height="180" />    <!-- iOS 8.0+ --> <!-- iPhone 6 Plus  -->
        <icon src="www/res/icon/ios/icon-60.png"         width="60"   height="60" />     <!-- iOS 7.0+ --> <!-- iPhone / iPod Touch  -->
        <icon src="www/res/icon/ios/icon-60-2x.png"      width="120"  height="120" />    <!-- iOS 7.0+ --> <!-- iPhone / iPod Touch  -->
        <icon src="www/res/icon/ios/icon-76.png"         width="76"   height="76" />     <!-- iPad -->
        <icon src="www/res/icon/ios/icon-76-2x.png"      width="152"  height="152" />    <!-- iPad -->
        <icon src="www/res/icon/ios/icon-40.png"         width="40"   height="40" />     <!-- iOS 6.1 --> <!-- Spotlight Icon -->
        <icon src="www/res/icon/ios/icon-40-2x.png"      width="80"   height="80" />     <!-- iOS 6.1 --> <!-- Spotlight Icon -->
        <icon src="www/res/icon/ios/icon-57.png"         width="57"   height="57" />     <!-- iPhone / iPod Touch -->
        <icon src="www/res/icon/ios/icon-57-2x.png"      width="114"  height="114" />    <!-- iPhone / iPod Touch -->
        <icon src="www/res/icon/ios/icon-72.png"         width="72"   height="72" />     <!-- iPad -->
        <icon src="www/res/icon/ios/icon-72-2x.png"      width="144"  height="144" />    <!-- iPad -->
        <icon src="www/res/icon/ios/icon-small29.png"    width="29"   height="29" />     <!-- iPhone Spotlight and Settings Icon -->
        <icon src="www/res/icon/ios/icon-small29-2x.png" width="58"   height="58" />     <!-- iPhone Spotlight and Settings Icon -->
        <icon src="www/res/icon/ios/icon-small29-3x.png" width="87"   height="87" />     <!-- iPhone Spotlight and Settings Icon -->
        <icon src="www/res/icon/ios/icon-50.png"         width="50"   height="50" />     <!-- iPad Spotlight and Settings Icon -->
        <icon src="www/res/icon/ios/icon-50-2x.png"      width="100"  height="100" />    <!-- iPad Spotlight and Settings Icon -->
    </platform>
</widget>

    package.json:
--- Start of Cordova JSON Snippet ---
{
  "plugins": {
    "cordova-plugin-dialogs": {},
    "cordova-plugin-globalization": {},
    "cordova-plugin-device": {},
    "cordova-plugin-email-composer": {},
    "cordova-plugin-inappbrowser": {},
    "cordova-plugin-network-information": {},
    "cordova-plugin-splashscreen": {},
    "cordova-plugin-statusbar": {},
    "cordova-support-google-services": {},
    "@havesource/cordova-plugin-push": {
      "ANDROIDX_CORE_VERSION": "1.6.+",
      "FCM_VERSION": "18.+",
      "IOS_FIREBASE_MESSAGING_VERSION": "~> 6.32.2"
    }
  },
  "platforms": [
    "ios",
    "browser",
    "android"
  ]
}
imperyal commented 1 year ago

Another thing I noticed, in the builds that the phonegap settings are removed there is this warning:

Conflict found, edit-config changes from config.xml will overwrite plugin.xml changes