objective c - iOS deep linking: how to embed URL in another URL? -
i need deep link app url, if custom scheme is:
myapp://
then deep linking url looks like:
myapp://?type=url&url=[another url]
the problem "another url" may contain separators ?, /, & etc, thought using quotation mark:
myapp://?type=url&url="http://another.url"
however url may have quotation mark in it, there way it?
thanks
you need escape of special characters in 2nd url. use utility method wrote help:
+ (nsstring *)encodestring:(nsstring *)string { nsstring *result = (__bridge_transfer nsstring *)cfurlcreatestringbyaddingpercentescapes(kcfallocatordefault, (__bridge cfstringref)string, null, cfstr("% '\"?=&+<>;:-#\\/~`!"), kcfstringencodingutf8); return result; }
with in place (in helper class or added category), can following:
nsstring *link = @"http://another.url"; nsstring *escapedlink = [someutility encodestring:link]; nsstring *myurl = [nsstring stringwithformat:@"myapp://?type=url&url=%@", escapedlink];
note encodestring:
method should used escape url parameter value may ever use build query string of url.
Comments
Post a Comment