I am making player which going to support Google DFP adserver. The Ad-server has a VAST link which is XML type and contains media-file, track links, clickLink etc...
The clickLinks includes a redirecting url to the original url which I could not properly decode.
The link looks like: https://pubads.g.doubleclick.net/aclk?sa=L&ai=B2JSpRFcKVq_SAsifbr-gqPAE9-CGpQcAAAAQASCPsd4lOABY37Owp4gCYJn-noa4IboBCzYyNHgzNTJfeG1syAEF2gEFaHR0cDqpArGOjXR685U-wAIC4AIA6gIULzEzMTMwMjQwNy9Vem1hbl9Ea3n4AvTRHpADhAeYA4QHqAMB0ASQTuAEAZAGAaAGI9gHAQ&num=0&cid=5Ggrgwo88gHDUD7JBb6uTLxZ&sig=AOD64_0xhsqN4jSnVOZ-eKo9KCVTet61iQ&client=ca-pub-3069068742246799&adurl=http://dkykartal.com/%3Futm_source%3DUzmanTV%26utm_medium%3DVideo_PreRoll%26utm_content%3DDKY_Kartal%26utm_campaign%3DDKY_Kartal_IBillBoard
I tried to decode by using stringByAddingPercentEscapesUsingEncoding
and then encode again but NSURL seems to be broken.
Original VastURL is:
https://pubads.g.doubleclick.net/gampad/ads?sz=624x352&iu=/131302407/Uzman_Dky&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=[referrer_url]&description_url=[description_url]&correlator=1443516172
How can properly cast this to an NSURL
?
Read your question again, carefully. You say you want to decode the URL and call a method that's called
stringByAddingPercentEscapesUsingEncoding
^^^^^^
Try using stringByRemovingPercentEncoding
. This should decode your URL.
To the other question, how to "cast" it to NSURL: Casting means you are forcing the debugger to treat a variable like a specific type. Meaning you cannot cast an object and turn it into an instance of another type.
You have to create an instance of NSURL using a string:
NSURL *URL = [NSURL URLWithString:[URLString stringByRemovingPercentEncoding]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With