Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Data error using Update Platform Config hook #253

Open
felquis opened this issue Oct 9, 2015 · 2 comments
Open

Invalid Data error using Update Platform Config hook #253

felquis opened this issue Oct 9, 2015 · 2 comments

Comments

@felquis
Copy link

felquis commented Oct 9, 2015

I found this hook here and I installed /hooks/after_prepare/update_platform_config.js

I'm making fixes related to iOS9 App Transport Security, more info here and at amazon here

<platform name="ios">
  <config-file platform="ios" target="*-Info.plist" parent="CFBundleURLTypes">
      <key>NSAppTransportSecurity</key>
      <dict>
        <key>NSExceptionDomains</key>
        <dict>
          <key>amazonaws.com</key>
          <dict>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSIncludesSubdomains</key>
            <true/>
          </dict>
          <key>amazonaws.com.cn</key>
          <dict>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSIncludesSubdomains</key>
            <true/>
          </dict>
        </dict>
      </dict>
  </config-file>
</platform>

But, I'm getting this error:

image

Does anyone know what I'm doing wrong?

@felquis
Copy link
Author

felquis commented Oct 10, 2015

So, the problem is that the hook only support Android and iOS and I'm also using browser platform.

Also, I figured out that we do not need to read the files into ./platforms to know what is the platforms used.

Just do:

// Main
(function () {

    if (rootdir) {
        // go through each of the platform directories that have been prepared
        var platforms = process.env.CORDOVA_PLATFORMS.split(',');

More infos in the section Non-JavaScript here

if I run

cordova prepare

process.env.CORDOVA_PLATFORMS will be all the platforms used delimited with comma , example android,ios,browser

if I run

cordova prepare ios

process.env.CORDOVA_PLATFORMS will be just ios

and running

cordova prepare android ios

process.env.CORDOVA_PLATFORMS will be android,ios

As it only works for Android and iOS, I ignored all the other platforms.

Final

// Main
(function () {
    var supportedPlatforms = ['android', 'ios'];
    if (rootdir) {
        // go through each platform that have been prepared
        var platforms = process.env.CORDOVA_PLATFORMS.split(',');

        platforms = _.filter(platforms, function (platform) {
          return supportedPlatforms.indexOf(platform) !== -1;
        });

        _.each(platforms, function (platform) {
            try {
                platform = platform.trim().toLowerCase();
                platformConfig.updatePlatformConfig(platform);
            } catch (e) {
                process.stdout.write(e);
            }
        });
    }
}());

Looks like it was already fixed in a pull request #228 #199 so I'm wont send pull request to fix it, I'll keep this issue open since any of these pull requests were merged.

@azachar
Copy link

azachar commented Jul 12, 2016

Hi there, I am having a similar issue

    throw new TypeError('invalid data');
    ^

TypeError: invalid data
    at Socket.write (net.js:617:11)
    at .../hooks/after_prepare/update_platform_config.js:373:24

Could you please advice what to do?

This is my config.xml

  <platform name="android">
        <preference name="android-minSdkVersion" value="22" />
        <preference name="android-targetSdkVersion" value="22" />
        <config-file target="AndroidManifest.xml" parent="/manifest">
          <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="23" />
          <uses-permission android:name="android.permission.RECORD_AUDIO" />
          <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
          <uses-permission android:name="android.permission.CAMERA" />
          <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        </config-file>
    </platform>

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants