Uploaded image for project: 'AeroGear'
  1. AeroGear
  2. AEROGEAR-9729

[cordova] phonegap-plugin-push configuration conflict with custom configuration

XMLWordPrintable

    • RC3
    • ER1
    • Service Team-Sprint 28
    • Hide

      Install latest version of cordova

      npm install -g cordova 
      

      create a new cordova app

      cordova create test
      cd test/
      

      edit the config.xml:

       <?xml version='1.0' encoding='utf-8'?>
      <widget id="io.cordova.hellocordova" version="1.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>HelloCordova</name>
          <description>
              A sample Apache Cordova application that responds to the deviceready event.
          </description>
          <author email="dev@cordova.apache.org" href="http://cordova.io">
              Apache Cordova Team
          </author>
          <content src="index.html" />
          <plugin name="cordova-plugin-whitelist" spec="1" />
          <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:*" />
          <platform name="android">
              <allow-intent href="market:*" />
              <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
                  <application android:usesCleartextTraffic="true" />
              </edit-config>
      	<resource-file src="google-services.json" target="app/google-services.json" />
          </platform>
          <platform name="ios">
              <allow-intent href="itms:*" />
              <allow-intent href="itms-apps:*" />
          </platform>
      </widget>
      

      add the cordova-plugin-aerogear-push

      cordova plugin add @aerogear/cordova-plugin-aerogear-push
      

      create a fake google-services.json

      {
        "project_info": {
          "project_number": "1",
          "firebase_url": "https://a.firebaseio.com",
          "project_id": "a",
          "storage_bucket": "a.appspot.com"
        },
        "client": [
          {
            "client_info": {
              "mobilesdk_app_id": "1:1:android:a",
              "android_client_info": {
                "package_name": "io.cordova.hellocordova"
              }
            },
            "oauth_client": [
              {
                "client_id": "1-a.apps.googleusercontent.com",
                "client_type": 3
              }
            ],
            "api_key": [
              {
                "current_key": "a"
              }
            ],
            "services": {
              "appinvite_service": {
                "other_platform_oauth_client": [
                  {
                    "client_id": "1-a.apps.googleusercontent.com",
                    "client_type": 3
                  }
                ]
              }
            }
          }
        ],
        "configuration_version": "1"
      }
      

      build the android app

      cordova platform add android
      cordova build android
      

      verify then the AndroidManifest.xml

      cat platforms/android/app/src/main/AndroidManifest.xml 
      
      Show
      Install latest version of cordova npm install -g cordova create a new cordova app cordova create test cd test/ edit the config.xml: <?xml version= '1.0' encoding= 'utf-8' ?> <widget id= "io.cordova.hellocordova" version= "1.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>HelloCordova</name> <description> A sample Apache Cordova application that responds to the deviceready event. </description> <author email= "dev@cordova.apache.org" href= "http: //cordova.io" > Apache Cordova Team </author> <content src= "index.html" /> <plugin name= "cordova-plugin-whitelist" spec= "1" /> <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:*" /> <platform name= "android" > <allow-intent href= "market:*" /> <edit-config file= "AndroidManifest.xml" mode= "merge" target= "/manifest/application" > <application android:usesCleartextTraffic= " true " /> </edit-config> <resource-file src= "google-services.json" target= "app/google-services.json" /> </platform> <platform name= "ios" > <allow-intent href= "itms:*" /> <allow-intent href= "itms-apps:*" /> </platform> </widget> add the cordova-plugin-aerogear-push cordova plugin add @aerogear/cordova-plugin-aerogear-push create a fake google-services.json { "project_info" : { "project_number" : "1" , "firebase_url" : "https: //a.firebaseio.com" , "project_id" : "a" , "storage_bucket" : "a.appspot.com" }, "client" : [ { "client_info" : { "mobilesdk_app_id" : "1:1:android:a" , "android_client_info" : { "package_name" : "io.cordova.hellocordova" } }, "oauth_client" : [ { "client_id" : "1-a.apps.googleusercontent.com" , "client_type" : 3 } ], "api_key" : [ { "current_key" : "a" } ], "services" : { "appinvite_service" : { "other_platform_oauth_client" : [ { "client_id" : "1-a.apps.googleusercontent.com" , "client_type" : 3 } ] } } } ], "configuration_version" : "1" } build the android app cordova platform add android cordova build android verify then the AndroidManifest.xml cat platforms/android/app/src/main/AndroidManifest.xml
    • Hide

      Downgrade to cordova 8

      npm install -g cordova@8
      
      Show
      Downgrade to cordova 8 npm install -g cordova@8

      When creating a plain cordova app using cordova 9 the phonegap-plugin-push configuration is not applied correctly.

      The expected result of the AndroidManifest.xml after built should be:

      <?xml version='1.0' encoding='utf-8'?>
      <manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" xmlns:android="http://schemas.android.com/apk/res/android">
          <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
          <uses-permission android:name="android.permission.INTERNET" />
          <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
              <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
                  <intent-filter android:label="@string/launcher_name">
                      <action android:name="android.intent.action.MAIN" />
                      <category android:name="android.intent.category.LAUNCHER" />
                  </intent-filter>
              </activity>
              <activity android:exported="true" android:name="com.adobe.phonegap.push.PushHandlerActivity" 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>
          </application>
          <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
          <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
          <uses-permission android:name="android.permission.WAKE_LOCK" />
          <uses-permission android:name="android.permission.VIBRATE" />
      </manifest>
      
      

      but the obtained result is:

      <?xml version='1.0' encoding='utf-8'?>
      <manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" xmlns:android="http://schemas.android.com/apk/res/android">
          <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
          <uses-permission android:name="android.permission.INTERNET" />
          <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
              <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
                  <intent-filter android:label="@string/launcher_name">
                      <action android:name="android.intent.action.MAIN" />
                      <category android:name="android.intent.category.LAUNCHER" />
                  </intent-filter>
              </activity>
          </application>
          <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
          <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
          <uses-permission android:name="android.permission.WAKE_LOCK" />
          <uses-permission android:name="android.permission.VIBRATE" />
      </manifest>
      
      

              danielpassos Daniel Passos (Inactive)
              dbizzarr@redhat.com Davide Bizzarri (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: