ios - Sending an URL alongside text using WhatsApp URL scheme -
i'm trying send text accompanied url using whatsapp's custom url scheme. there's apparently 1 valid parameter purpose: text
:
nsurl *whatsappurl = [nsurl urlwithstring:@"whatsapp://send?text=hello%2c%20world!"];
the problem comes when want append own url text. opted encode using this:
nsstring *encodedurlstring = (nsstring *)cfbridgingrelease(cfurlcreatestringbyaddingpercentescapes( null, (cfstringref)urlabsolutestring, null, (cfstringref)@"!*'();:@&=+$,/?%#[]", kcfstringencodingutf8 ));
the url sent whatsapp alongside text doesn't decoded on whatsapp's side:
any ideas? thank you!
you're approaching correctly, appears url being double-encoded. make sure both message , url encoded once.
using same encoding method, can so:
nsstring *urlabsolutestring = @"hello world! http://yayvisitmysiteplease.com?funky=parameter&stuff"; nsstring *encodedurlstring = ...
that should give url execute:
whatsapp://send?text=hello%20world%21%20http%3a%2f%2fyayvisitmysiteplease.com%3ffunky%3dparameter%26stuff
that makes way whatsapp you'd expect. (i verified make double sure.)
Comments
Post a Comment