相关疑难解决方法(0)

使用whatsapp分享链接

我在这个应用程序中使用这些代码进行共享应用程序链接,但在whatsapp的文本字段中没有任何内容.如果使用简单的文本然后它的工作.任何人都可以提出最终结果.

NSString *theTempMessage = @"whatsapp://send?text=https://itunes.apple.com/in/app/myapp/id1054375332?ls=1&mt=8";
NSString *theFinalMessage;

theTempMessage = [theTempMessage stringByReplacingOccurrencesOfString:@":" withString:@"%3A"];
theTempMessage = [theTempMessage stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"];
theTempMessage = [theTempMessage stringByReplacingOccurrencesOfString:@"?" withString:@"%3F"];
theTempMessage = [theTempMessage stringByReplacingOccurrencesOfString:@"," withString:@"%2C"];
theTempMessage = [theTempMessage stringByReplacingOccurrencesOfString:@"=" withString:@"%3D"];
theFinalMessage = [theTempMessage stringByReplacingOccurrencesOfString:@"&" withString:@"%26"];

NSString * stringToSend=theFinalMessage;
NSURL *whatsappURL = [NSURL URLWithString:stringToSend];

if ([[UIApplication sharedApplication] canOpenURL: whatsappURL])

{
    [[UIApplication sharedApplication] openURL: whatsappURL];
}
Run Code Online (Sandbox Code Playgroud)

objective-c ios whatsapp

17
推荐指数
2
解决办法
1万
查看次数

使用WhatsApp URL方案在文本旁边发送URL

我正在尝试使用WhatsApp的自定义URL方案发送一些带有URL的文本.为此目的,显然只有一个有效参数text:

NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
Run Code Online (Sandbox Code Playgroud)

当我想将自己的URL附加到该文本时,就会出现问题.我选择使用它编码它:

NSString *encodedURLString = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
                                                                                  NULL,
                                                                                  (CFStringRef)urlAbsoluteString,
                                                                                  NULL,
                                                                                  (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                                                  kCFStringEncodingUTF8 ));
Run Code Online (Sandbox Code Playgroud)

该URL与文本一起发送到WhatsApp,但不会在WhatsApp方面解码:

WhatsApp没有解码URL

有任何想法吗?谢谢!

cocoa objective-c ios whatsapp

7
推荐指数
2
解决办法
2万
查看次数

如何在iOS上分享WhatsApp上的内容

我想从我的应用程序中分享一个Url链接和一些短信到WhatsApp.我该如何分享内容?

我得到的代码只有文字

NSString * msg = @"Trueman India Magazine";
NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

if ([[UIApplication sharedApplication] canOpenURL: whatsappURL])
    {
        [[UIApplication sharedApplication] openURL: whatsappURL];
    }
Run Code Online (Sandbox Code Playgroud)

但我如何在WhatsApp中分享我的网址链接?

ios whatsapp

3
推荐指数
1
解决办法
1328
查看次数

标签 统计

ios ×3

whatsapp ×3

objective-c ×2

cocoa ×1