【发布时间】:2016-05-22 11:41:18
【问题描述】:
以下是我用来在 WhatsApp 上分享文字的内容
NSString *globalString;
NSString *myURl = [NSString stringWithFormat:@"http://www.mywebq8.com/mobile/newsdetails.aspx?id=%@", [global getstrProDetails]];
globalString =[NSString stringWithFormat: @"%@ للمزيد \n\n%@",[global getstrPagetitle], myURl];
NSLog(@"globalString===%@", globalString);
NSString * msg = globalString;
NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@", msg ];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
} else {
UIAlertView *mAl = [[UIAlertView alloc] initWithTitle:@"" message:@"Your device doesn't have WhatsApp." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[mAl show];
}
下面是我的 NSLog 输出。
حاول الانتحار فألقى بنفسه بين أسود.. وخرج حياً للمزيد
http://www.mywebq8.com/mobile/newsdetails.aspx?id=22455
当我点击 WhatsApp 图标时,它会打开 WhatsApp,但显示中没有显示消息...它只是显示空白。
知道为什么会这样吗?
注意:我的另一个项目是相同的代码,它于 2016 年 5 月 9 日更新。
编辑 1
即使我在下面尝试仍然无法正常工作
This is test text
http://www.mywebq8.com/mobile/newsdetails.aspx?id=22455
【问题讨论】:
-
您的代码是正确的,您的消息存在问题 NSString *myURl = [NSString stringWithFormat:@"mywebq8.com/mobile/newsdetails.aspx?id=22455"]; globalString =[NSString stringWithFormat: @"بين أسود.. وخرج حياً للمزيد للمزيد \n \n%@", myURl]; 如果您发送 NSString * msg=@"hello stackflow"; 它工作正常,请检查您的文本。
标签: ios objective-c share whatsapp