Git Product home page Git Product logo

Comments (5)

stowy avatar stowy commented on July 28, 2024

Hi,

Can you capture the response and perhaps provide a sample project? We are unable to reproduce this error locally.

Thanks

Sam

from googleads-consent-sdk-ios.

accidbright avatar accidbright commented on July 28, 2024

Tested with SDK version 1.0.1, issue is still the same.
Here is sample project, that can show issue: https://github.com/accidbright/PACConsentSample
Here are the response headers:

<NSHTTPURLResponse: 0x1c8032980> { URL: https://adservice.google.com/getconfig/pubvendors?es=2&plat=ios&v=1.0.1&pubs=pub-0123456789012345 } { Status Code: 200, Headers {
    "Access-Control-Allow-Origin" =     (
                                         "*"
                                         );
    "Cache-Control" =     (
                           private
                           );
    "Content-Disposition" =     (
                                 "attachment; filename=\"f.txt\""
                                 );
    "Content-Encoding" =     (
                              gzip
                              );
    "Content-Length" =     (
                            5545
                            );
    "Content-Type" =     (
                          "application/json; charset=windows-1251"
                          );
    Date =     (
                "Fri, 25 May 2018 09:01:27 GMT"
                );
    Server =     (
                  cafe
                  );
    "alt-svc" =     (
                     "hq=\"googleads.g.doubleclick.net:443\"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=\"googleads.g.doubleclick.net:443\"; ma=2592000; v=\"43,42,41,39,35\",hq=\":443\"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=\":443\"; ma=2592000; v=\"43,42,41,39,35\""
                     );
    p3p =     (
               "policyref=\"https://www.googleadservices.com/pagead/p3p.xml\", CP=\"NOI DEV PSA PSD IVA IVD OTP OUR OTR IND OTC\""
               );
    "timing-allow-origin" =     (
                                 "*"
                                 );
    "x-content-type-options" =     (
                                    nosniff
                                    );
    "x-xss-protection" =     (
                              "1; mode=block"
                              );
} }

from googleads-consent-sdk-ios.

accidbright avatar accidbright commented on July 28, 2024

Already found the issue by myself. There is encoding problem. According to official Apple docs the method JSONObjectWithData:options:error: expects UTF encoding:

The data must be in one of the 5 supported encodings listed in the JSON specification: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE.

But data in response is encoded with CP1251. That is not supported by this method.

As the solution I can offer next code:

NSString * dataString = [[NSString alloc] initWithData:data encoding:NSWindowsCP1251StringEncoding];
NSData * dataInUTFEncoding = [dataString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary<NSString *, id> *info = [NSJSONSerialization JSONObjectWithData:dataInUTFEncoding options:0 error:&error];

instead of existing:

// From file PACPersonalizedAdConsent.m:328
NSDictionary<NSString *, id> *info = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];

This code works for me.

from googleads-consent-sdk-ios.

hei9gag avatar hei9gag commented on July 28, 2024

I can reproduce this error using real device but not in simulator

from googleads-consent-sdk-ios.

Izzyjm avatar Izzyjm commented on July 28, 2024

has this issue been fixed ? why does it fail only on 10.3.3 and 11.3 ? if apple only supports "UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE" then how is it even working at all with CP1251 on non 10.1 and 11.3 devices & how come mine says charset=ISO-8859-1 and not windows1251? @hei9gag @accidbright

from googleads-consent-sdk-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.