当前位置:  开发笔记 > 编程语言 > 正文

如何在iOS应用程序的什么应用程序上分享链接和短信?

如何解决《如何在iOS应用程序的什么应用程序上分享链接和短信?》经验,为你挑选了1个好方法。



1> Jay Bhalani..:

试试这段代码:

NSString * msg = @"Application%20Name%20https://itunes.apple.com/YOUR-URL";

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

NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg];
NSURL * whatsappURL = [NSURL URLWithString:urlWhats];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL])
{
    [[UIApplication sharedApplication] openURL: whatsappURL];
}
else
{
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
}

推荐阅读
地之南_816
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有